View Full Version : !forumid = '19' doesn't work!
Swedie
Fri 7th Mar '03, 5:14am
Hey.. I'm making a script that lists the latest threads in the forum. Well, that part works splendid, but i'm having brainfarts right now and I can't seem to get how to do so that the script excludes results where forumid = 19.
This is what I've tried with and it doesn't work very well:
$result = mysql_query("SELECT * FROM thread WHERE !forumid = '1' ORDER BY lastpost DESC LIMIT 8") or die("Invalid Query: " . mysql_error());
Any idea what the problem is?
Chen
Fri 7th Mar '03, 5:16am
Should be forumid <> 1.
Scott MacVicar
Fri 7th Mar '03, 5:17am
code is a bit different
try forumid <> 19
mysql doesn't have a != operator
Chen
Fri 7th Mar '03, 5:17am
code is a bit different
try forumid <> 19
mysql doesn't have a != operator
Yeah it does, try this:
SELECT 1 != 0;
Scott MacVicar
Fri 7th Mar '03, 5:19am
SELECT * FROM vb3_forum WHERE forumid != 2
You have an error in your SQL syntax near '!= 2 LIMIT 0, 30' at line 1
ok in that case my mysql is insane
Chen
Fri 7th Mar '03, 5:30am
What version are you running?
squall14716
Fri 7th Mar '03, 5:32pm
I use something like:
SELECT * FROM table WHERE field!='value';
Hell, to be truthful, I never use <>. I think though, that you need the quotes for mysql's !=, not sure though.
Swedie
Fri 7th Mar '03, 6:44pm
Cool. thanks
So, what if when I want to have more than one FORUMID excluded from the result?
MUG
Fri 7th Mar '03, 6:58pm
WHERE forumid NOT IN(1,2,3,4,5,6)
Swedie
Sat 8th Mar '03, 1:00am
WHERE forumid NOT IN(1,2,3,4,5,6)
that's a new one...
So that will work too? you're not messing with me :p
Chen
Sat 8th Mar '03, 5:20am
Yes that'll work too. There's also IN which does the opposite.
vBulletin® v3.8.0 Beta 3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.