Beginner

88. NULL in WHERE Clause

Learn how NULL values behave when filtering records with the WHERE clause.

📘 Lesson 88 of 728 ⏱ 8 min 🎯 Beginner

NULL cannot be tested using normal equality or inequality comparisons. SQL provides IS NULL and IS NOT NULL specifically for filtering NULL values.

Incorrect NULL filtering can cause valid records to be missed and produce inaccurate reports.

To find employees without a department assigned, use WHERE Department IS NULL instead of WHERE Department = NULL.

SQL
SELECT
    EmployeeID,
    EmployeeName
FROM Employees
WHERE Department IS NULL;

This is important for data-quality checks, incomplete records, customer information, employee records, and database validation.

  • Use IS NULL to find NULL values.
  • Use IS NOT NULL to find available values.
  • Do not use = NULL.
  • Do not rely on normal comparisons for NULL.
  • Correct NULL filtering improves data accuracy.
How do you filter rows containing NULL?

Use the IS NULL operator.

Why does WHERE Column = NULL not work as expected?

NULL represents an unknown value, so SQL uses IS NULL rather than the normal equality operator.

Have you finished this lesson?

Introduction to SQL – All Lessons