Hi all,
I need an sql query that will retrieve all items that have both tags, not any of tags. I already have a query but returns all items that hove both tags, not expected result. Find detailed description below. Thanks!
Table structure:
ITEMS TABLE
------------
item_id
item_name
TAGS TABLE
----------
tag_id
tag_name
ITEMTAGS TABLE
---------------
tag_id
item_id
Query:
SELECT Items.* FROM Items
INNER JOIN ItemTags ON Items.item_id = ItemTags.item_id
WHERE ItemTags.tag_id IN (T1, T2)
GROUP BY Items.item_id
Result: All items that have T1 or T2
Expected result: All items that have both T1 and T2