SELECT DISTINCT group_id FROM mark_mapping
WHERE subcat_id = 22 AND subcat_id = 30 AND subcat_id = 17 AND subcat_id = 18 AND subcat_id = 19
This is my sample query. As you know.. this is not working. Help me please.
Here subcat_id may can repeat more than 10 times. All are same columns.
I would like to metion my table structure here....
group_id subcat_id
12 -------> 7
12 -------> 8
12 -------> 9
12 -------> 10
13 -------> 7
13 -------> 11
14 -------> 8
14 -------> 9
so on.. So what is the correct to get this result...
SELECT DISTINCT group_id FROM mark_mapping WHERE subcat_id = 22 AND subcat_id = 30 AND subcat_id = 17 AND subcat_id = 18 AND subcat_id = 19
SELECT group_id FROM mark_mapping WHERE subcat_id in (22,30,17,18,19) group by group_id having count(distinct subcat_id) = 5
I know that the AND statement is looking for different column. Can any one tell me how can I use it for a column...