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!

SQL Select Null values

Status
Not open for further replies.

maxf

Programmer
Oct 2, 2002
25
US
Im simply trying to select all the values in my table for which there is a null value but Im unable to get the query right. Im using

Select * from orders where IsNull(status)


This isnt working. How can I do this?

thanks
 
Select * from orders where status is null

Note the syntax: is null not = null.

Nothing equals a null including another null.

 
Sorry. I was not correct.
The correct syntax is IS NULL

i.e.
SELECT * FROM tblProduct WHERE Status IS NULL
 
Just to expand
IsNull()
is a function that takes 2 parameters. The first is the value to be tested the 2nd is the value you return if the 1st IS NULL else the 1st value is returned.

status = NULL

does not work because the nature of NULL

Just like
NULL + 5 = NULL not 5
 
Something to add.

Maybe you had been using Access or VB or something similar because there there is a function like ISNULL(expression) which returns TRUE if expression is NULL and FALSE in any other case (this function also can be used in querys written in access). ISNULL( ) in TRANSACT SQL is like discribed above.

Iker
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top