col1 col2
null null
aaaa null
bbbb null
col1=col2 - no rows returned
not (col1=col2) - following returned
aaaa null
bbbb null
Not (null) = null? so how is this being interpreted?
col1 col2
null null
aaaa null
bbbb null
col1=col2 - no rows returned
not (col1=col2) - following returned
aaaa null
bbbb null
Not (null) = null? so how is this being interpreted?
Comparing with null
results in unknown which is false
.
Use the is
operator
where col1 = col2
or (col1 is null and col2 is null)
I added the ()
only for readabiliy. and
has stronger operator precendence than or
.
Please use isnull(col1,0)=isnull(col2,0) because can't compare null with logical operations.
see below link: SQL is null and = null