Back to SQL Notes
Topic #88

SQL IS NULL / IS NOT NULL

NULL means "no value" — not zero, not an empty string, not false. You can never test for it with =; you need IS NULL or IS NOT NULL.

Syntax

WHERE column IS NULL
WHERE column IS NOT NULL

Sample Table: employees

namemanager_id
Aman3
RiyaNULL
KaranNULL

Riya and Karan have no manager on record — manager_id is NULL, meaning "unknown / not set," not zero.

Example

SELECT name FROM employees
WHERE manager_id IS NULL;

Output: Riya, Karan.

Why WHERE manager_id = NULL Never Works

-- WRONG — always returns zero rows, no error
SELECT name FROM employees WHERE manager_id = NULL;

In SQL's three-valued logic, comparing anything to NULL with = — including NULL = NULL — evaluates to UNKNOWN, not TRUE. Rows are only returned when a condition is TRUE, so this silently returns nothing, with no error to warn you.

NULL and Aggregate Functions

COUNT(*) counts all rows regardless of NULLs, but COUNT(column) and functions like AVG(column) ignore NULL values in that column entirely — they don't treat NULL as zero. See COALESCE for substituting a default value.

Practical Use Case

Finding incomplete records — customers with no phone number, orders with no delivery date yet, employees with no assigned manager.

Common Mistakes

  • Using = NULL or != NULL instead of IS NULL / IS NOT NULL
  • Assuming an empty string '' is the same as NULL — they're different values and require different filters
  • Forgetting NULL's effect inside NOT IN subqueries (see IN)

Interview Relevance

"Why doesn't WHERE column = NULL work?" is one of the most commonly asked SQL fundamentals questions — understanding three-valued logic (TRUE / FALSE / UNKNOWN) separates candidates who've memorized syntax from those who understand it.

Practice Question

Write a query to find all orders where the delivered_date column has not been set yet.

Want to go beyond the notes?

Join Coding Now Tech Institute's SQL course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

SQL IS NULL / IS NOT NULL – FAQs

Quick answers about learning SQL IS NULL / IS NOT NULL in SQL.

This free note from Coding Now Tech Institute explains SQL IS NULL / IS NOT NULL in SQL — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every SQL topic on Coding Now Tech Institute, including SQL IS NULL / IS NOT NULL, is 100% free with no signup required.
With focused practice, most students grasp SQL IS NULL / IS NOT NULL in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now