Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««910111213

NULL Equals NULL? Expand / Collapse
Author
Message
Posted Sunday, November 09, 2008 6:14 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Sunday, April 06, 2014 12:29 AM
Points: 17, Visits: 75
Hi,

That really explains why my query werent pulling out any records...
Well I was able to solve the problem by modifying it as below:

select phonenumber

from ttemp

where phonenumber

not in

(

select '7'+phonenumber

from tpphone

where phonecountrycode = '64'

and phoneareacode = '07'

and phonenumber is not null

)

However the query was taking a long time to execute and I had to pull my outer query into a temporary table to get things done.

Post #599618
Posted Wednesday, January 13, 2010 7:27 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, October 29, 2013 6:02 AM
Points: 147, Visits: 426
I haven't seen mention of this important NULL topic anywhere:

select 1
where 1 = 1 or datediff(hour, null, getdate()) > 4

TSQL seems to work like this:

where True OR NULL = True
where False OR NULL = False

where True AND NULL = False
where False AND NULL = False

which seems good to me

but I still think this syntax would be useful:

where coalesce(datediff(hour, [field], getdate()) > 4, 0)

letting you coalesce a boolean without using dummy values
Post #846880
Posted Monday, August 09, 2010 3:34 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, April 14, 2014 4:18 PM
Points: 1,276, Visits: 1,132
DataDog (1/13/2010)
I haven't seen mention of this important NULL topic anywhere:

select 1
where 1 = 1 or datediff(hour, null, getdate()) > 4

TSQL seems to work like this:

where True OR NULL = True
where False OR NULL = False

where True AND NULL = False
where False AND NULL = False

which seems good to me

but I still think this syntax would be useful:

where coalesce(datediff(hour, [field], getdate()) > 4, 0)

letting you coalesce a boolean without using dummy values


Actually, this:

datediff(hour, null, getdate()) > 4

Works out to this:

NULL > 4

Which returns 'UNKNOWN'. So your truth table entry for:

where 1 = 1 or datediff(hour, null, getdate()) > 4

Is actually:

True OR Unknown = True

That's covered fairly well in a lot of places--a lot of articles on this site, for instance or BOL.

Thanks
Mike C
Post #966281
« Prev Topic | Next Topic »

Add to briefcase «««910111213

Permissions Expand / Collapse