Ad space (banner)
🗄️SQL Lessons
Lesson 15 / 50

Working with NULL Values

This lesson covers handling NULL values in SQL, so you can correctly detect and process "missing data." It's for anyone searching "SQL NULL check" or "SQL IS NULL."

NULL represents "no value has been entered yet." Test for it with IS NULL / IS NOT NULL, and use COALESCE() to substitute a fallback value when a column is NULL.

The example uses COALESCE(score, 0) to treat Bob's NULL score as 0 instead. This is the classic use case: whenever a raw NULL would break a calculation or look ugly on screen, substitute something more useful.

A common early mistake is writing = NULL to test for null — that never works, because NULL represents "unknown/unset," not the number zero or an empty string. You always need the dedicated IS NULL syntax. Optional fields like a phone number or nickname are routinely NULL in real databases, so handling it correctly is an unavoidable, foundational database skill.

SQL
OUTPUT

💡 The SQL engine may take a few seconds to load the first time you run code.

Ad space (banner)
Ad space (in-article)