I want to create filter query which uses AND and OR on many to many relation table.
Table consists only of 2 columns id_product and id_category
My query I'm using, but its not working:
SELECT id_product FROM id_category WHERE ( id_category = 1) AND (id_category = 2)
AND ( id_category = 3 OR id_category = 4 OR id_category = 5) GROUP BY id_product
I would like to retrieve products that are in categories at the same time. Only IDs of products which are in category 1 AND 2 AND (3 or 4 or 5)
id_categorycannot be at the same time1and2.. So seems natural that aWHERE ( id_category = 1) AND ( id_category = 2) [..etc]will always return an empty result