Thanks Chris,
By the way do you have problems with spammers getting your gmail address
from usenet?
The user_id is actually what I'm searching for dynamically, so my initial
query was relatively correct as it returns one row with user 1.
However, I wasn't familiar with the concept of
Hello,
I am trying to find out how to search a many-to-many map table efficiently.
I have an example table:
user,user_group
1,1
1,2
2,1
3,2
I want to find out all the users who are a member of BOTH groups 1 AND 2. In
this example, this would just be the user with id 1.
Until now, I can
Steve McGill wrote:
Hello,
I am trying to find out how to search a many-to-many map table efficiently.
I have an example table:
user,user_group
1,1
1,2
2,1
3,2
I want to find out all the users who are a member of BOTH groups 1 AND 2. In
this example, this would just be the user with id 1.
you must have three tables
user (have at least user_id field)
group (have at least groupd_id field)
user_group (have 2 fields: user_id and group_id, you can also have
user_group_id - depends on your need)
/* if you only need the user id */
select user_id from user_group where group_id in (1,2);