I want only those products which satisfies following condition :
Which have ((category_id = 1 OR category_id = 2) AND (category_id = 3 OR category_id = 4))
Database structure:
products
id int(10)
name varchar(128)
categories
Id int (10)
name varchar(64)
category_products
product_id int(10)
category_id int(10)
Data:
My product details are:
Products:
id name
1 P1
2 P2
3 P3
4 P4
My category details are:
Categories:
Id name
1 C1
2 C2
3 C3
4 C4
My category-product mapping details are:
category_products:
product_id category_id
1 1
1 3
1 4
2 2
3 1
3 2
3 3
3 4
4 1
4 4
Final Output should be:
id
1
3
4