The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Query syntax help needed
I'm trying to create a list of my Registered Users (primary usergroup #2)that are NOT also in secondary group #12. I've tried this
Code:
SELECT email, username FROM user WHERE (usergroupid=2 AND NOT(membergroupids=12)); I don't know if it is germane, but users CAN be in more than one secondary group on my board, so the membergroupids entry for a user could be a series of group numbers strung together with commas, like "8,9,12,13". I'd greatly appreciate it if somebody could help with the correct query syntax. |
#2
|
||||
|
||||
SELECT email, username
FROM user WHERE usergroupid =2 AND membergroupids !=12 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) |
#3
|
||||
|
||||
Quote:
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:
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. |
#4
|
|||
|
|||
..AND NOT FIND_IN_SET(12, membergroupids)...
|
#5
|
||||
|
||||
Have already created the list using NOT LIKE ...
.. but will add this to my bag o' tricks for next time. Thanks, Marco! |
#6
|
|||
|
|||
You can not do the trick with a (NOT) LIKE.
Example: Member A, Membergroupids: '1,4,123' Member B, Membergroupids: '12,31' Looking for '%4%' would give you the correct result, but using '%12%' would also match the '123', and that is not what you want. |
#7
|
||||
|
||||
Quote:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|