I have a table like this:
So an ID can have more than one category. I want to select records that are in both category 3 and 4.
If I make an SQL statement with OR, I'll get all the items for category 3 and category 4. But if I do an and, I'll get no records.
Do I need to make a temporary table with:
Or do I run 2 queries, 1 for the first category and 1 for the second category and then find the duplicates?
What is the best way to do this?
Thanks,
/Wendy
Code:
id cat_id
1 3
2 3
3 3
1 4
2 5
If I make an SQL statement with OR, I'll get all the items for category 3 and category 4. But if I do an and, I'll get no records.
Do I need to make a temporary table with:
Code:
id cats
1 3,4
2 3,5
3 3
Or do I run 2 queries, 1 for the first category and 1 for the second category and then find the duplicates?
What is the best way to do this?
Thanks,
/Wendy