List:General Discussion« Previous MessageNext Message »
From:Michael Stassen Date:May 10 2005 8:42pm
Subject:Re: Comparing to null queries
View as plain text  
Mike Rykowski wrote:
> Hello,
> 
> I have a query:
> 
> select * from table where del != "1";
> 
> Let's assume that I have a record where del is null (del is a single
> character field).
> 
> In version 3.23.22-beta I get the record returned with the above query,
> in version 4.1.10a I get nothing returned.
> 
> Did something change between these versions or is this a bug?  I
> couldn't find anything specific to this on the archives.
> 
> TIA

You should get nothing returned.  NULL is not a value, so it cannot be 
equal, *or not equal*, to anything.  The result of NULL != 1 is NULL. 
NULL is not TRUE, so no rows where del is NULL should be returned.  If 
3.23.222-beta returned such rows, it was a bug in that ancient version 
which has since been fixed.

If you want rows where del is null, you need to

   SELECT * FROM table WHERE del IS NULL;

Michael
Thread
Comparing to null queriesMike Rykowski10 May
  • Re: Comparing to null queriesmfatene10 May
  • Re: Comparing to null queriesMichael Stassen10 May
  • Re: Comparing to null queriesPeter Brawley10 May