Let's say I have two tables, "Parent" and "Child". Parent-to-Child is a many:many relationship, implemented through a standard cross-referencing table.
I want to find all records of Parent that are referenced by ALL members of a given set of Child using SQL (in particular MS SQL Server's T-SQL; 2005 syntax is acceptable).
For example let's say I have:
- List item
- Parent Alice
- Parent Bob
- Child Charlie references Alice, Bob
- Child David references Alice
- Child Eve references Bob
My goals are:
- If I have Children Charlie, I want the result set to include Alice and Bob
- If I have Children Charlie and David, I want the result set to include Alice and NOT Bob.
- If I have Children Charlie, David, and Eve, I want the result set to include nobody.