The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
SQL Help - Searching from multiple usergroups
[sql]$db->query_first("SELECT homepage AS url FROM user WHERE usergroupid = 5 || 6 || 7 || 9 ||12 AND homepage != '' AND lastpost > UNIX_TIMESTAMP(NOW())-86400 ORDER BY RAND() LIMIT 1");[/sql]
The query above works only with 2 numbers in the usergroupid field (one OR). Once I move it up to 3 it fails to work correctly. How do I fix? |
#2
|
|||
|
|||
Why is the limit 1 there? I thought that meant after getting one found stop. Remove the limit 1 and see what happens.
|
#3
|
|||
|
|||
The LIMIT 1 needs to be there. I only need one random homepage, but it selected (randomly) from several different usergroups.
|
#4
|
|||
|
|||
[sql]
$db->query_first("SELECT homepage AS url FROM user WHERE usergroupid IN (5,6,7,9,12) AND homepage != '' AND lastpost > UNIX_TIMESTAMP(NOW())-86400 LIMIT 1"); [/sql] |
#5
|
|||
|
|||
Thanks a bunch.
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|