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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

char wierdness 1

Status
Not open for further replies.

azzazzello

Technical User
Jan 25, 2005
297
US
MysqL version 5.0.7

I have a table where a field blah is of type char(1). All of the rows have blah as NULL. When I do this

Code:
SELECT * from mytable WHERE blah != 'B' LIMIT 5;

I get an empty set. Huh?!? I tried it with a bunch of other fields, of types datetime, varchar, int. All nicely return 5 rows where blah is NULL (aka, not equal to 'B'). What gives?
 
NULL is not equal to anything

more importantly, NULL is not not equal to anything, either

basic three-valued logic

i'd be interested in seeing your script or sample data that demonstrates the other NULL datatypes that were returned for <>'B'

r937.com | rudy.ca
 
wow, I did not know this - thank you. I screwed up in my testing: I changed the WHERE condition to another field, but never changed the what SELECT gets, so it was still selecting blah. Which explains why it returned NULL. The other fields I was testing had non-null fields which obviously did not equal to 'B', but since I was selecting blah I couldn't see what they were :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top