I have the following problem with the logic for a table join and hope someone here will be able to push me into the right direction.
I have table A with several records and table B with 0-n rows for each record in table A (basically a dynamic list of attributes for each entry in A).
Now I would like to fetch all records from A which do not have a defined list of entries in B (basically "give me all records which do not have all required attributes").
I believe that the following query would provide me with all matches but as I mentioned I'd be looking for the opposite.
SELECT * FROM A
LEFT JOIN B ON p1.fk=c.id
GROUP BY B.attr_name, A.id
HAVING B.attr_name IN (SELECT 'ATTR1' AS attr UNION ALL SELECT 'ATTR2' UNION ALL SELECT 'ATTR3')
Anyone who can shed a bit of light into this?