mercredi 4 février 2015

Delete from SQLite table with join to link table

I have these tables:


item:



+ _id
+ timestamp


itemlists:



+ _id
+ timestamp


linktable:



+ _id
+ item_id foreign key references items(_id)
+ item_list_id foreign key references item_list(_id)


I now want to delete an item_list and all items in it. However I don't want to delete any items from the items table if they are in another list.


I can retrieve all items for a playlist:



items a inner join item_list b on a._id = b.item_id where item_list_id = ?


But I'm struggling with how to structure a delete for a list. Any pointers in the right direction are highly appreciated.


I'm running this on SQLite on Android.


Aucun commentaire:

Enregistrer un commentaire