Det enklaste vore att använda group by
och having
:
SELECT group_name
FROM table2 g
JOIN table1 t on g.group_id = t.group_id
WHERE t.item in (765,656)
GROUP BY group_name
HAVING COUNT(DISTINCT t.item) = 2
Det enklaste vore att använda group by
och having
:
SELECT group_name
FROM table2 g
JOIN table1 t on g.group_id = t.group_id
WHERE t.item in (765,656)
GROUP BY group_name
HAVING COUNT(DISTINCT t.item) = 2