View Single Post

   
  #7 (permalink)  
Old 02-28-2008, 08:15 AM
Peter H. Coffin
 
Posts: n/a
Default Re: weird results: (null!=null)??

On Tue, 26 Sep 2006 12:11:34 +0200, alex wrote:
> I've got this select:
>
> select * from table1,table2 where table1.field1=table2.field1 and
> table1.field2=table2.field2
>
> and it does not return any rows for the elements where both "field2" are
> null.
>
> the only way i can get those rows is using this query:
>
> select * from table1,table2 where table1.field1=table2.field1 and
> table1.field2=table2.field2 or (table1.field2 is null and table2.field2
> is null)
>
> is this the normal behaviour? is there any other way in which those rows
> where both fields are null are returned?


This is normal. NULL cannot be compared to anything else, even another
"value of NULL", because NULL does not have a value. Comparing NULL
returns a NULL result as well, neither true nor false.

--
"The last refuge of the insomniac is a sense of superiority to the
sleeping world."
--Leonard Cohen, The Favourite Game
Reply With Quote