article_id cat_id
70 7
70 8
71 9
71 8
I need article_id
where cat_id=8
and cat_id=7
and the result must return 70.
I tried this code but neither worked:
SELECT *
FROM andishkadeh_article_catgory
WHERE cat_id=6 AND cat_id=8
SELECT *
FROM andishkadeh_article_catgory
WHERE cat_id in (6,8)
SELECT article_id FROM my_table WHERE cat_id IN (7,8) GROUP BY article_id HAVING COUNT(*) = 2;
and note that article_catgory_id is redundant, so I removed it. Your PRIMARY KEY would be formed on(article_id,cat_id)