0% found this document useful (0 votes)
46 views2 pages

Understanding NULL Values in SQL

A NULL value in SQL indicates a field with no value, distinct from zero or spaces. To test for NULL values, the IS NULL and IS NOT NULL operators must be used instead of comparison operators. The document provides examples of how to query a database for NULL values using these operators.

Uploaded by

Bogdan Chindris
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views2 pages

Understanding NULL Values in SQL

A NULL value in SQL indicates a field with no value, distinct from zero or spaces. To test for NULL values, the IS NULL and IS NOT NULL operators must be used instead of comparison operators. The document provides examples of how to query a database for NULL values using these operators.

Uploaded by

Bogdan Chindris
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

SQL 

NULL Values

What is a NULL Value?


A field with a NULL value is a field with no value.

If a field in a table is optional, it is possible to insert a new record or update a


record without adding a value to this field. Then, the field will be saved with a
NULL value.

Note: A NULL value is different from a zero value or a field that contains
spaces. A field with a NULL value is one that has been left blank during record
creation!

How to Test for NULL Values?


It is not possible to test for NULL values with comparison operators, such as =,
<, or <>.

We will have to use the IS NULL and IS NOT NULL operators instead.

IS NULL Syntax
SELECT column_names
FROM table_name
WHERE column_name IS NULL;

IS NOT NULL Syntax


SELECT column_names
FROM table_name
WHERE column_name IS NOT NULL;
Demo Database
Below is a selection from the "Customers" table in the Northwind sample
database:

CustomerID CustomerName ContactName Address

1 Alfreds Futterkiste Maria Anders Obere Str. 5

2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la

3 Antonio Moreno Taquería Antonio Moreno Mataderos

4 Around the Horn Thomas Hardy 120 Hanove

5 Berglunds snabbköp Christina Berglund Berguvsväg

You might also like