I need some help with some code
I have a database table called \"stuff\" and I have this info:
+------+-------------+---------------------+
| id | memb
The problem is called Relational Division
.
SELECT group_id
FROM stuff
WHERE member_id IN (11,22,33)
GROUP BY group_id
HAVING COUNT(*) = 3
if member_id
is not unique for every group_id
, you need to have DISTINCT
in order to count only unique values.
SELECT group_id
FROM stuff
WHERE member_id IN (11,22,33)
GROUP BY group_id
HAVING COUNT(DISTINCT member_id) = 3
More variations on this link: