This is a discussion on AND-conjunction of rows within the MySQL General forum forums, part of the MySQL category; --> Hi list, I have three tables: product (ID, name) product2attribute (ID, product, attribute) attribute (ID, name) Product <-> Attribute ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi list, I have three tables: product (ID, name) product2attribute (ID, product, attribute) attribute (ID, name) Product <-> Attribute is an n:m relation, so one product can have two or more attributes and of course there can be many products with an attribute. I want to select alle products that have attribute A and attribute B. The only query that came to my mind was something like SELECT * FROM product WHERE EXISTS (SELECT * FROM product2attribute WHERE attribute = ...) AND EXISTS (SELECT * FROM product2attribute WHERE attribute = ...). Is this the correct and only query to accomplish that? Regards, André |