SQL NULL Values – IS NULL and IS NOT NULL with Examples (2026-27)
In SQL, a NULL value represents missing, unknown, or absent data in a database field. NULL is not the same as zero, not the same as an empty string '', and not the same as false — it literally means no value was recorded. Understanding NULL is critical because standard comparison operators like = and != do not work with NULL — you must use the special IS NULL and IS NOT NULL operators. In this beginner-friendly guide you will learn what NULL means, how to find and filter NULL values, how to update NULLs, how COALESCE replaces NULL with a default, and the most important mistakes to avoid.
✅ What is NULL in SQL?
✅ NULL means a field has no value — the data is missing, unknown, or was never entered.
✅ NULL is not zero, not empty string, and not false — it is the complete absence of a value.
✅ Any comparison with NULL using =, !=, <, or > returns UNKNOWN — not TRUE or FALSE.
✅ Sample Employees Table (with NULL values shown in red):-
| ID | Name | Department | Salary | Phone |
|---|---|---|---|---|
| 1 | ANNI | IT | 10000 | 9876543210 |
| 2 | POOJA | IT | 90000 | NULL |
| 3 | RAJ | HR | 5000 | 9123456789 |
| 4 | SUJAN | HR | 8000 | NULL |
| 5 | MEENA | Sales | 12000 | 9988776655 |
POOJA (ID=2) and SUJAN (ID=4) have no phone number recorded — their Phone column is NULL.
✅ IS NULL and IS NOT NULL Syntax
-- Find rows where the column IS NULL (missing value):
SELECT column1, column2, ...
FROM table_name
WHERE column_name IS NULL;
-- Find rows where the column IS NOT NULL (has a value):
SELECT column1, column2, ...
FROM table_name
WHERE column_name IS NOT NULL;
✅ IS NULL:- Returns rows where the column has no value.
✅ IS NOT NULL:- Returns rows where the column has a value.
= NULL or != NULL — these always return no rows because NULL cannot be compared with standard operators. Always use IS NULL or IS NOT NULL.
✅ Example 1 – Find Rows with NULL (IS NULL)
Find all employees whose phone number is missing.
✅ SELECT Query:-
SELECT * FROM Employees
WHERE Phone IS NULL;
✅ Result:-
| ID | Name | Department | Salary | Phone |
|---|---|---|---|---|
| 2 | POOJA | IT | 90000 | NULL |
| 4 | SUJAN | HR | 8000 | NULL |
✅ Example 2 – Find Rows without NULL (IS NOT NULL)
Find all employees who have a phone number recorded.
✅ SELECT Query:-
SELECT * FROM Employees
WHERE Phone IS NOT NULL;
✅ Result:-
| ID | Name | Department | Salary | Phone |
|---|---|---|---|---|
| 1 | ANNI | IT | 10000 | 9876543210 |
| 3 | RAJ | HR | 5000 | 9123456789 |
| 5 | MEENA | Sales | 12000 | 9988776655 |
✅ Example 3 – Update NULL Values
Update POOJA's phone number (previously NULL) to a real number.
✅ UPDATE Query:-
UPDATE Employees
SET Phone = '9000000001'
WHERE ID = 2;
✅ Result — After Update:-
| ID | Name | Department | Salary | Phone |
|---|---|---|---|---|
| 1 | ANNI | IT | 10000 | 9876543210 |
| 2 | POOJA | IT | 90000 | 9000000001 |
| 3 | RAJ | HR | 5000 | 9123456789 |
| 4 | SUJAN | HR | 8000 | NULL |
| 5 | MEENA | Sales | 12000 | 9988776655 |
SET Phone = NULL WHERE ID = 4. This clears the phone number for SUJAN, making the field NULL again.
✅ Example 4 – COUNT with NULL Values
Understanding how NULL affects COUNT() is essential for accurate reporting.
✅ SELECT Query:-
-- COUNT(*) counts ALL rows including NULLs:
SELECT COUNT(*) AS TotalEmployees FROM Employees;
-- COUNT(column) counts only NON-NULL values:
SELECT COUNT(Phone) AS EmployeesWithPhone FROM Employees;
✅ Result:-
| Query | Result |
|---|---|
| COUNT(*) | 5 |
| COUNT(Phone) | 3 |
✅ Example 5 – COALESCE: Replace NULL with a Default Value
COALESCE returns the first non-NULL value from a list of arguments — perfect for displaying a fallback when a column is NULL.
✅ SELECT Query:-
SELECT Name,
COALESCE(Phone, 'Not Provided') AS PhoneNumber
FROM Employees;
✅ Result:-
| Name | PhoneNumber |
|---|---|
| ANNI | 9876543210 |
| POOJA | Not Provided |
| RAJ | 9123456789 |
| SUJAN | Not Provided |
| MEENA | 9988776655 |
ISNULL(Phone, 'Not Provided') works the same way in SQL Server — returns 'Not Provided' when Phone is NULL. COALESCE is the standard SQL version that works across all databases.
✅ NULL vs Empty String vs Zero
| Concept | NULL | Empty String ('') | Zero (0) |
|---|---|---|---|
| Meaning | No value / unknown | Value entered but blank | Numeric value of zero |
| Data type | Any | Text (VARCHAR) | Numeric (INT, etc.) |
| IS NULL check | TRUE | FALSE | FALSE |
| = '' check | UNKNOWN | TRUE | Error / FALSE |
| = 0 check | UNKNOWN | Error / FALSE | TRUE |
| In COUNT(col) | Not counted | Counted | Counted |
WHERE Phone = '' and WHERE Phone IS NULL are completely different queries. Empty strings and NULLs are stored and behave differently — never confuse them.
✅ How NULL Affects Aggregate Functions
| Function | Handles NULL? | Behaviour |
|---|---|---|
COUNT(*) | ✅ Counts NULLs | Counts all rows regardless of NULLs |
COUNT(column) | ❌ Skips NULLs | Counts only non-NULL values in that column |
SUM(column) | ❌ Skips NULLs | Adds only non-NULL values; NULL treated as 0 |
AVG(column) | ❌ Skips NULLs | Calculates average of non-NULL values only |
MAX(column) | ❌ Skips NULLs | Returns maximum of non-NULL values |
MIN(column) | ❌ Skips NULLs | Returns minimum of non-NULL values |
✅ Key Points to Remember
✅ NULL = missing or unknown data — not zero, not empty string.
✅ Use IS NULL — to find rows with no value in a column.
✅ Use IS NOT NULL — to find rows that have a value in a column.
✅ Never use = NULL or != NULL — always returns no results (UNKNOWN).
✅ COALESCE(col, 'default') — replaces NULL with a fallback value in SELECT output.
✅ COUNT(*) includes NULLs — COUNT(column) skips NULLs.
✅ SUM, AVG, MAX, MIN all ignore NULLs — only non-NULL values are used.
✅ NULL in NOT IN list — can cause the entire NOT IN query to return zero rows.
✅ Common SQL NULL Mistakes to Avoid
Wrong:
WHERE Phone = NULL — always returns zero rows.Correct:
WHERE Phone IS NULL — the only way to find NULL values.
Wrong:
WHERE Phone != NULL — always returns zero rows.Correct:
WHERE Phone IS NOT NULL.
WHERE Phone = '' finds rows with empty strings — NOT NULL rows. These are completely different storage types. Always check which one your data contains before filtering.
WHERE Department NOT IN ('IT', NULL) returns zero rows — NULL in a NOT IN list breaks the entire comparison. Always ensure your NOT IN list has no NULLs. Use IS NOT NULL as an additional filter if needed.
✅ Frequently Asked Questions (FAQ)
WHERE column_name IS NULL returns rows where the column has no value. Use IS NOT NULL: WHERE column_name IS NOT NULL returns rows where the column has a value. Never use = NULL or != NULL.NULL IS NULL returns TRUE, but '' IS NULL returns FALSE.SELECT COALESCE(Phone, 'Not Provided') FROM Employees returns 'Not Provided' for any row where Phone is NULL. In SQL Server, ISNULL(Phone, 'Not Provided') works the same way.