Understanding SQL NULL
NULL means 'unknown' or 'missing' — not zero, not an empty string, and genuinely not equal to anything, including another NULL.
What & Why
NULL represents an absent or unknown value. A missing product.feedback.nps_score does not mean a score of zero or an empty string; it means no NPS score was submitted for that feedback row.
NULL is not equal to anything, including another NULL. NULL = NULL evaluates to UNKNOWN, which is why SQL provides IS NULL and IS NOT NULL for missing-value tests.
See How It Works
Product wants to compare = NULL with IS NULL against the real nullable nps_score column.
| id | user_id | feature_id | rating | nps_score | comment | created_at |
|---|---|---|---|---|---|---|
| 1 | 101 | 1 | 5 | 9 | Clear and useful | 2024-01-25 12:15:00+00 |
| 2 | 102 | 2 | 4 | NULL | Export worked well | 2024-02-20 15:40:00+00 |
| 3 | 103 | 1 | 4 | 7 | Helpful setup flow | 2024-03-18 09:05:00+00 |
| 4 | 104 | 3 | 3 | NULL | Needs clearer timing | 2024-04-08 17:30:00+00 |
| id | nps_score | expression | result |
|---|---|---|---|
| 2 | NULL | NULL = NULL | UNKNOWN |
Ordinary equality with NULL is UNKNOWN—even when the stored NPS score is NULL.
SELECT
id,
nps_score,
nps_score = NULL AS equals_null,
nps_score IS NULL AS is_null
FROM product.feedback
ORDER BY id;Practice this concept
Product compares = NULL with IS NULL against the real nullable nps_score column.
productPrefix tables with product.table_name.
idnps_scoreequals_nullis_nullproduct.feedback| Column | Type |
|---|---|
| id | integer |
| user_id | integer |
| feature_id | integer |
| rating | integer |
| nps_score | integer |
| comment | text |
| created_at | timestamp with time zone |
| moderation_bucket | text |
Sign up free to try it on a real business scenario