First of all, i'm new to sql.
Now, I'm building a tagging system with sqlite for my android app that uses 3 tables (items, tags, tagmap) based on this "toxi" solution found here, but I'm not sure on how the mechanics work, how would I select all items from this itemsTable that have a specific tag.
itemsTable
itemid
2
3
4
tagsTable
tagid tag
2 "ruby"
3 "java"
7 "c"
tagmap
itemid tagid
2 3
3 7
2 2
4 7
I was trying something along the lines of:
SELECT* FROM itemsTable INNER JOIN tagmap ON tagmap.itemid= itemsTable.itemid AND tagmap.tagid=tagsTable.tagid WHERE tagsTable.tagid= desiredid
But this seems to be wrong.
BTW: all itemid and tagsid are primary keys auto-incremented
Any answers or an alternative to creating a tagging system(in which an item can have more than one tag) are welcomed.
Aucun commentaire:
Enregistrer un commentaire