Skip to main content
Module 4 · Lesson 2 of 414/57 in the course~14 min
Module lessons (2/4)

Handling NULLs: IS NULL and COALESCE

Lesson preview5 hands-on exercises readySQL Course · Module 4 — Practical SQL

Detect missing values reliably and replace NULLs with sensible defaults.

What you'll learn in this lesson

  • Understand the three-valued logic SQL (TRUE, FALSE, UNKNOWN) introduced by NULL.
  • Use IS NULL, IS NOT NULL and IS DISTINCT FROM correctly (never = NULL).
  • Replace missing values with COALESCE(...) and protect splits with NULLIF(...).

Overview

In SQL NULL is neither zero nor an empty string: it means "unknown or absent value". This is precisely why comparing any value to NULL via = or <> produces neither TRUE nor FALSE, but rather UNKNOWN — causing subtle bugs in the WHERE clauses.

Explore with the stepper how LEFT JOIN keeps rows unmatched by producing NULL cells on the right side, which SELECT then elegantly transforms with COALESCE:

Sections covered in this lesson

  1. 11. Mental Model: Three-Valued Logic
  2. 22. Progressive & Annotated Examples
  3. 33. Interactive Laboratory: When NULLs Survive the JOIN
  4. 44. Diagnostic Verification (Quiz)
  5. 55. Progressive Practical Laboratory
Pro Lesson · Module 4 — Practical SQL

Unlock "Handling NULLs: IS NULL and COALESCE" and the full SQL Course curriculum

Detect missing values reliably and replace NULLs with sensible defaults.

Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in SQL Course plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.