Problemet kaldes Relational Division
.
SELECT group_id
FROM stuff
WHERE member_id IN (11,22,33)
GROUP BY group_id
HAVING COUNT(*) = 3
hvis member_id
er ikke unik for hver group_id
, skal du have DISTINCT
for kun at tælle unikke værdier.
SELECT group_id
FROM stuff
WHERE member_id IN (11,22,33)
GROUP BY group_id
HAVING COUNT(DISTINCT member_id) = 3
Flere varianter af dette link: