 <pre><code>select g.person_id from @person_groups g inner join @tempGroupList l on g.group_id = l.group_id group by g.person_id having count(distinct g.group_id) = (select count(*) from @tempGroupList); </code></pre> <p>To explain slightly. The <code>inner join</code> restricts us to just the groups in question. The <code>group by</code> allows us to calculate the number of different (distinct) groups each person is in. The <code>having</code> filters down to the people in the right number of distinct groups.</p> <p>If a person can only appear once in each group (i.e. <code>group_id, person_id</code> is a unique combination in <code>@person_groups</code>) then you don't need the <code>distinct</code>.</p>