Say I have 2 tables, called parent and child. A parent can have zero to many children, and a child can have 1 to many parents. How do I find all the parent elements that are par
An alternative to the accepted answer, probably faster:
SELECT p.* FROM parent p JOIN join_table j ON p.id=j.parent_id WHERE j.child_id=1 OR j.child_id=2 GROUP BY j.parent_id HAVING COUNT(j.child_id)=2;