The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
SQL syntax help
I was hoping that somebody might be able to help me with this problem:
Firstly, I have created a new table in my forums db called userclass and in it there are 2 fields: userclassid & title. Then i have added a field to the user table called 'userclassid' as well and have successfully been able to modify the user.php to enable me to assign a class title to each user. In addition to this i have added a field to the usergroup table called 'rollcall' which is simply a 1 or 0, so i can assign wether or not i wish for these usergroups to appear in the rollcall. (just like the showgroups function does for the showgroups.php) The problem i have is in this query that was originaly from the showgroups.php, i cannot work out how i should write it I would like it so that it will list users in groups of class and only those who have been assigned '1' in the usergroup.rollcall table. The below Query displays them almost as i want but it lists each user 5 times!! lol oh and it also seems to display users regardless of the WHERE clause :/ PHP Code:
|
#2
|
||||
|
||||
try that one:
PHP Code:
|
#3
|
|||
|
|||
woah! nice one !!!
Works a treat!!! Thanks alot Xenon ... juuuuuust one more thing: its in reverse alphabetical order, anyway to switch that ? The usernames are i mean. |
#4
|
||||
|
||||
welcome
add ORDER BY username ASC after the where clause |
#5
|
|||
|
|||
Thanks a million made me very happy
|
#6
|
|||
|
|||
how can i make it so that it WONT list members who haven't yet got a 'userclassid' please?
I've tried using the NOT 0 syntax but i keep getting errors |
#7
|
||||
|
||||
use that where:[sql]WHERE usergroup.rollcall = 1 AND user.userclassid != 0[/sql]
|
#8
|
||||
|
||||
use mine
|
#9
|
|||
|
|||
Code:
SELECT DISTINCT userclass.title, user.userid, user.gender, user.username, user.userclassid, user.usergroupid FROM user LEFT JOIN userclass ON (userclass.userclassid = user.userclassid !=0) LEFT JOIN userfield ON (userfield.userid = user.userid) LEFT JOIN usergroup ON (usergroup.usergroupid = user.usergroupid) WHERE usergroup.rollcall = 1 ORDER BY username ASC "); err its different to yours |
#10
|
|||
|
|||
have hehe, thanks again Xenon, your a star
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|