Reputation: 711
Let's say on the MySQL Table, userid=A and userid=B.
userid=A belongs to Group1, Group5, Group6, Group8
userid=B belongs to Group2, Group9, Group5, Group10.
What's MYSQL query statement of finding the two users's common group which is Group5 in this case.
The intersection query
Upvotes: 0
Views: 38
Reputation: 1636
select * from group_table where group_id = id AND (userid = a or userid = b)
if the count is 2 then they're both members of the group.
Upvotes: 2