Code has been added to clipboard!

SQL NULL Value Explained: How to Use IS NULL & IS NOT NULL

Reading time 1 min
Published Aug 9, 2017
Updated Oct 11, 2019

SQL NULL Values: Main Tips

  • This value defines lost data.
  • Tables already contain NULL values.
  • NULL is handled not like other values.

SQL Working with NULL Values

Below there is a table called "People":

ID Last_Name First_Name Address City
1 Bob Bola Nesdan
2 Bill Bove Ergan 13 Nesdan
3 Benny Bari Nesdanger

Hypothetically the "Adress" column is optional. Then when you write a data record without a value assigned it will receive NULL.

Testing is unavailable using default operators, that's why we use IS NULL/IS NOT NULL.

IS NULL: Example

To select NULL data records we use IS NULL operator:

Example
SELECT col_names
FROM tbl_name
WHERE col_name IS NULL;
Example
SELECT Name, Unit 
FROM Products 
WHERE Unit_On_Order IS NULL;

IS NOT NULL: Example

To select data records with no NULL values we use IS NOT NULL operator:

Example
SELECT col_names
FROM tbl_name
WHERE col_name IS NOT NULL;
Example
SELECT Name, Price 
FROM Products 
WHERE Unit_On_Order IS NOT NULL;
Learn SQL
Introduction
Syntax
Data Types
Server Data Types
Commands
Commands List
Wildcards
Constraints
Aggregate Functions
Date Functions
Date Format
Injection
SQL Server Hosting
Views
Auto-incrementation
SQL Operators
AS
AND & OR
IN
BETWEEN
WHERE
GROUP BY
HAVING
ORDER BY
LIKE
NOT
NOT EQUAL
UNION
NULL
NOT NULL
DEFAULT
UNIQUE
FOREIGN KEY
PRIMARY KEY
CHECK
Indexes
ALTER TABLE
CREATE DATABASE
CREATE TABLE
DELETE
DROP
INSERT INTO SELECT
INSERT INTO
SELECT
SELECT DISTINCT
SELECT INTO
SELECT TOP
UPDATE
FULL OUTER JOIN
INNER JOIN
JOIN
LEFT JOIN
RIGHT JOIN
AVG()
COUNT
FIRST
LAST
MAX
MIN()
SUM()
LEN
UCASE
MID
NOW
ROUND
FORMAT
LOWER
CONVERT
ISNULL