Return all users from group(s) specified as comma delimited value
Posted
by
todor
on Stack Overflow
See other posts from Stack Overflow
or by todor
Published on 2012-09-30T20:05:57Z
Indexed on
2012/10/02
3:37 UTC
Read the original article
Hit count: 101
I have the following two table scenario:
users
id groups
1 1,2,3
2 2,3
3 1,3
4 3
and
groups
id
1
2
3
How do I return the IDs of all users that belong to group 2 and 1 for example? Should I look into join, a helper group_membership table or function to separate the comma delimited group IDs to get something like this:
group_membership
user_id group_id
1 1
1 2
1 3
2 2
2 3
... ...
© Stack Overflow or respective owner