List:General Discussion« Previous MessageNext Message »
From:André Hänsel Date:October 11 2006 12:53am
Subject:AND-conjunction of rows
View as plain text  
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é

Thread
AND-conjunction of rowsAndré Hänsel11 Oct