Handling NULL

NULL represents a missing or unknown value — not zero, not an empty string, just the absence of data. It behaves differently from every other value in SQL, which trips people up constantly.

Why = doesn't work on NULL

This lesson adds a manager column to the employees table. Ava and Sam don't have one, so their manager is NULL. You might expect this to find them:

this returns nothing
Result

It returns zero rows — not because nothing matches, but because NULL means "unknown," and SQL won't say an unknown value is equal to anything, even another NULL. You need a dedicated check instead:

IS NULL and IS NOT NULL

employees with no manager
Result
employees who do have a manager
Result

COALESCE

COALESCE returns the first non-NULL value from a list — a common way to substitute a friendlier default for display:

show 'None' instead of a blank
Result
Note: aggregate functions like COUNT(*) count every row including ones with NULLs, but COUNT(column) only counts rows where that specific column isn't NULL — worth remembering when your totals look off.