Why does checking for 'nothing' in your data never work the way you expect?
Why equals NULL fails in SQL - The Real Reasons
Imagine you have a list of friends and you want to find those whose phone number you don't know yet. You try to check if their phone number is equal to nothing, but it doesn't work as expected.
Using the usual equals sign (=) to check for unknown or missing values (NULL) doesn't work because NULL means 'unknown'. Comparing anything to unknown with = always fails or returns no results, making your search frustrating and incomplete.
SQL provides a special way to check for NULL values using IS NULL or IS NOT NULL. This lets you correctly find records where data is missing or unknown, solving the problem elegantly.
SELECT * FROM friends WHERE phone = NULL;
SELECT * FROM friends WHERE phone IS NULL;
This concept allows you to accurately find and handle missing or unknown data in your database queries.
When managing customer records, you can find all customers who haven't provided their email address yet by checking if the email field IS NULL.
NULL means unknown, not just empty or zero.
Using = NULL doesn't work because comparisons with unknown always fail.
Use IS NULL or IS NOT NULL to check for missing data correctly.