Module lessons (2/4)
Handling NULLs: IS NULL and COALESCE
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 byNULL. - Use
IS NULL,IS NOT NULLandIS DISTINCT FROMcorrectly (never= NULL). - Replace missing values with
COALESCE(...)and protect splits withNULLIF(...).
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
- 11. Mental Model: Three-Valued Logic
- 22. Progressive & Annotated Examples
- 33. Interactive Laboratory: When NULLs Survive the JOIN
- 44. Diagnostic Verification (Quiz)
- 55. Progressive Practical Laboratory
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.