Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problm with != in query 1

Status
Not open for further replies.

electricphp

Programmer
Feb 20, 2008
71
0
0
US
Why does this return results:

SELECT * FROM messages WHERE receiver_del = 'yes'

but this doesn't

SELECT * FROM messages WHERE receiver_del != 'yes'

There should be one result returned. there is one record that has the value in receiver_del set as yes.

The rest of the records have that field as null. maybe that has something to do with it?
 
Try using "<>".

SELECT * FROM messages WHERE receiver_del <> 'yes'
 
I'm not sure about MySQL, but some databases treat null differently. how about
Code:
SELECT * FROM messages WHERE ifnull(receiver_del,'no') != 'yes'
or
Code:
SELECT * FROM messages WHERE receiver_del IS NULL

-----------------------------------------
I cannot be bought. Find leasing information at
 
yes, this did it:

SELECT * FROM messages WHERE ifnull(receiver_del,'no') != 'yes'

seems like an awful lot of code for such a simple task
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top