The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
![]()
Can anybody help me with this querry? I have users that are in 2 membergroupids. That is 12 and 18.
When I write condition membergroupids = 12 it works fine and it pull out ousers that are in 12 membergroupids (aka additional usergroup). I guess this works only because 12 is recorderd as first id in table... 12,18... But when i try conditional membergroupids = 18; or I try membergroupids IN (18) neither doesnt work. Any idea why? How to accomplish this querry? Is it because there are two "IN" in the querry??? This is what I try and doesnt work for me: PHP Code:
|
#2
|
||||
|
||||
![]()
Are you sure that there are users whose membergroupid is 18?
|
#3
|
||||
|
||||
![]()
You have it backwards, it would be
Code:
18 IN (membergroupids) Use, Code:
find_in_set(18, membergroupids) |
#4
|
|||
|
|||
![]()
Hmm I tried this:
PHP Code:
Anyway i managed it with "membergroupids LIKE %18%" query and it works fine sofar. Thanks for your help and any further feedback is appreciated .-) |
#5
|
||||
|
||||
![]()
It's a MySQL function not a PHP function.
![]() Use it instead of IN |
#6
|
|||
|
|||
![]()
[sql]SELECT userid FROM " . TABLE_PREFIX . "user WHERE userid IN ($user) and membergroupids find_in_set(18, membergroupids)[/sql]
your way of doing the LIKE is not good as it will grab also members in group 118, 2187 etc... if you have that much usergroups.. lol |
#7
|
|||
|
|||
![]()
I am aware of that
![]() Ok so how to make it in correct way? I am getting syntax errror. PHP Code:
SELECT userid FROM user WHERE userid IN (17291,24998,19,8026,28994,56325) and membergroupids find_in_set(18, membergroupids); MySQL Error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'find_in_set(18, membergroupids)' at line 1 Error Number : 1064 |
#8
|
|||
|
|||
![]()
Should be:
PHP Code:
|
#9
|
||||
|
||||
![]()
And if you get touchy about vBulletin Coding Standards...
PHP Code:
|
#10
|
|||
|
|||
![]()
Thanks, it is good to learn handy stuff from beginning
![]() Thanks to all of you, your advice with find_ind_set is working great .-) |
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|