Quote:
Originally Posted by briansol
SELECT email, username
FROM user
WHERE usergroupid =2
AND membergroupids !=12
|
Thanks, this is close. It eliminates those that are ONLY in secondary group 12 (i.e. those where membergroupids = "12" but does not eliminate those that are in both groups 12 and 13 (i.e. membergroupids = "12,13") and maybe some other combinations that I haven't checked.
We need, not an inequality but a "not found in" check.
[Edit] I see you edited yours while I was writing the above reply. I'll try your additional suggestion and get back...
Quote:
Originally Posted by briansol
or perhaps if you have multiple groups:
SELECT u.email, u.username FROM user u
WHERE u.usergroupid=2
and u.userid != (select userid v from user v where v.membergroupids LIKE '%12%' and u.userid = v.userid)
|
Sadly, no go. Doesn't return anybody.
But combining the two approaches, it looks, on first blush, like this does work:
SELECT email, username
FROM user
WHERE usergroupid =2
AND membergroupids NOT LIKE '%12%'
I'll have to spot check a few users of known multiple group memberships, but so far I think that'll do it. Thanks for your help.