Skip to content
We areTOP 1%

Find Customer Referee

EasyLeetCodeSQL: SELECT & Filtering
Solve on LeetCode(opens in a new tab)
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews
Hint and exampleShow

A comparison with NULL is unknown rather than true, so add an explicit IS NULL check to keep the rows whose value is missing.

Example: students(name, mentor_id) — students not mentored by 4

name  | mentor_id
Asha  | 4
Ravi  | NULL
Kiran | 2
SELECT name
FROM students
WHERE mentor_id <> 4 OR mentor_id IS NULL;
-- returns Ravi, Kiran (without IS NULL, Ravi is lost)

More in SQL: SELECT & Filtering

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account