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é


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to