Monday, 4 April 2011

SQL IS NOT NULL

SQL IS NOT NULL

Look at the following "Persons" table:

P_Id
LastName
FirstName
Address
City
1HansenOla Sandnes
2SvendsonToveBorgvn 23Sandnes
3PettersenKari Stavanger



How do we select only the records with no NULL values in the "Address" column?
We will have to use the IS NOT NULL operator:

SELECT LastName,FirstName,Address FROM Persons
WHERE Address IS NOT NULL


The result-set will look like this:

LastName
FirstName
Address
SvendsonToveBorgvn 23

No comments:

Post a Comment