NULL handling pocket guide
Recall how NULL affects filters, counts, joins, and replacements.
Can I write column = NULL? Correction Use column IS NULL or column IS NOT NULL. NULL is not equal to anything, including itself. IS NULL tests the missing-value state directly. COUNT(*) versus COUNT(column) Choose based on whether missing values should count. What does COALESCE(value, 0) promise? It treats missing value as zero for this query output. Use only when that replacement is semantically honest. Why can NOT IN be risky with nullable subqueries? A NULL in the subquery can make comparisons unknown and remove expected rows. Prefer NOT EXISTS when keys may be NULL.
Sign up free — one personalized lesson every day, matched to your role and goals.
Already have an account? Sign in