This is the setting:
Table A has a connection to table B. Table B has several entries (from 0 to n) that may have a corresponding entry in table A.
How to generate a query that gives me an entry from table A only if a certain number of matching records exists in table B?
Example:
Table A has clothes. Table B has attributes for clothing.
Table B has a foreign key for table A, so it will look something like this:
id fid_clothing1 attributeA
id fid_clothing1 attributeB
id fid_clothing1 attributeC
id fid_clothing2 attributeA
id fid_clothing2 attributeB
Now I only want clothes that have the attributeAAND attributeBAND attribute attributeC. This is not a problem if I make an OR request, but I cannot just do something like:
SELECT * from tableA
LEFT JOIN tableB on tableB.fid_cloting = tableA.id
WHERE attribute='A' AND attribute='B' AND attribute='C'
This condition will never be true. How to do it?
swissdude