PDA

View Full Version : = works fine but != messed up the query?


sabret00the
01-27-2005, 02:32 PM
this is the query
$grps_newestmembers = $DB_site->query("
SELECT grps_user.groupid,grps_user.userid, user.username, grps_user.join_date,grps_user.mod_queue
FROM grps_user
LEFT JOIN user ON (user.userid = grps_user.userid)
WHERE grps_user.groupid = $groupid AND grps_user.mod_queue != 1
ORDER BY grps_user.join_date DESC
");

has php stopped supporing != overnight or am i just being stupid and doing something wrong?

Natch
01-27-2005, 02:42 PM
PHP is fine with it, but SQL prefers NOT (iirc)

Marco van Herwaarden
01-27-2005, 02:44 PM
Try "<>" instead of "!=" ;)

Lol a lot of different answers :D

IIRC "<>" is the official SQL notation, "!=" is added later i think (MySQL only???, what version??).

But what happens, you get an error, it don't function like expected?

sabret00the
01-27-2005, 02:49 PM
Try "<>" instead of "!=" ;)

Lol a lot of different answers :D

IIRC "<>" is the official SQL notation, "!=" is added later i think (MySQL only???, what version??).

But what happens, you get an error, it don't function like expected?
still returning nothing :(

the table looks like this

groupid userid username join_date mod_queue
7 10 sabret00the 1106842883 1
7 64 user2 1106661929 NULL


so it should return the one with NULL in it, shouldn't it?

But what happens, you get an error, it don't function like expected?no error it just returns no data :(

Marco van Herwaarden
01-27-2005, 02:58 PM
Are you 100% sure that $groupid contain "7"?

What are the fieldtypes?

Are these userid's in the user table?

PS you could try running it without the test on mod_queue to find where the error is.

Edit try changing that NULL value to 0.

sabret00the
01-27-2005, 03:43 PM
groupid is definately 7
fieldtypes, oh mod_queue is set at tinyint(4)
the userid's are in the grps_user table
it works without the mod_queue clause, it's just that that's causing the problem?
even with NULL set as 0 it don't work?

Dean C
01-27-2005, 03:47 PM
Change this:


$grps_newestmembers = $DB_site->query("
SELECT grps_user.groupid,grps_user.userid, user.username, grps_user.join_date,grps_user.mod_queue
FROM grps_user
LEFT JOIN user ON (user.userid = grps_user.userid)
WHERE grps_user.groupid = $groupid AND grps_user.mod_queue != 1
ORDER BY grps_user.join_date DESC
");


To this:


echo("
SELECT grps_user.groupid,grps_user.userid, user.username, grps_user.join_date,grps_user.mod_queue
FROM grps_user
LEFT JOIN user ON (user.userid = grps_user.userid)
WHERE grps_user.groupid = $groupid AND grps_user.mod_queue != 1
ORDER BY grps_user.join_date DESC
");


Show us what it outputs to the browser :)

sabret00the
01-27-2005, 03:50 PM
SELECT grps_user.groupid,grps_user.userid, user.username, grps_user.join_date,grps_user.mod_queue FROM grps_user LEFT JOIN user ON (user.userid = grps_user.userid) WHERE grps_user.groupid = 7 AND grps_user.mod_queue != 1 ORDER BY grps_user.join_date DESC

Dean C
01-27-2005, 04:01 PM
Ok we have some issues with your database model here. You have some data redundancy in the fact you have the username column in this grps_user table. Drop that column as you can get the users username via a join on the userid column. Also change the fieldtype of the mod_queue column to smallint, lenth 1, unsigned and default 0. Then try your query :up:

sabret00the
01-27-2005, 04:27 PM
oops, that username was never apart of the grps_user column

here's the table straight from phpmyadmin
recordid groupid userid join_date mod_queue
Edit Delete 4 3 10 1102848936 NULL
Edit Delete 3 2 10 1102848632 NULL
Edit Delete 13 6 10 1106781470 NULL
Edit Delete 12 3 64 1106777848 NULL
Edit Delete 9 2 64 1106568571 NULL
Edit Delete 10 7 64 1106661929 NULL
Edit Delete 14 6 64 1106781499 0
Edit Delete 16 7 10 1106842883 1

now i just ran a query to change al them nulls to 1 and it never worked, i think theirs something seriously wrong with the mod_queue column

i'm gonna try and delete it and reinstall it, as i have no idea why it won't work still.

works fine now :( changed it to in_mod_queue just to be safe and it's working fine.

thank you everyone, sorry to waste your time.