SQL NULL

When working with tables in SQL, you will sometimes encounter field values that are empty or missing, which is referred to as NULL.  This occurs during the creation of a record in a given table, when the field is not required to have a value.  This differs from zero values or spaces, and cannot be selected or evaluated using the traditional comparison operators.  In the case of SQL NULL values, you can identify using the IS NULL or IS NOT NULL operators, which will be demonstrated below.

SQL NULL – Sample Data

Say you have the following table

SQL NULL

SQL NULL – using the IS NULL syntax

To select all records where the field “Age” has a NULL value, execute the following sample code

Results

SQL NULL

SQL NULL – using the IS NOT NULL syntax

To select all records where the field “Age” has an actual value (Not NULL), execute the following sample code

Results

SQL NULL

I hope you find these simple examples useful!

 

 

Additional Content

Check out more examples by visiting my Home Page

Here you will find topics covering  Qlikview  SQL Server  Excel VBA

 

 

Leave a Comment