sql · level 1 · unit 4 · lesson 1
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
means nothing is there. Find it with .
In the books table, some books have no borrower because they are on the shelf. That box holds NULL, which means no value at all. It is not zero, and it is not text.
To find empty boxes, use IS NULL. To find full ones, use IS NOT NULL. Never write = NULL: it finds nothing, because nothing can equal an empty box.
When a result has an empty box, it shows the word NULL so you can spot it.
SELECT title FROM books WHERE borrower IS NULL; NULL needs no quotes, because 'NULL' in quotes is the word NULL written as text.
guess first
Short books only. What will this show?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
SELECT title, author FROM books WHERE pages < 140;
your turn
Your turn. Which books are out on loan?
Books out on loan have a borrower, so their borrower box is not empty. Finish the test so the query finds them, then press run.
result
Your answer appears here as a table.
fix it
Every book on the shelf has vanished. Fix it!
result
Your answer appears here as a table.
- There is no error, but there are no rows either. Look at how the query checks for an empty box.
- Nothing can equal an empty box, so
= NULLnever passes. - Change = NULL to IS NULL, then press run.
nailed it
you found the empty boxes. :D
NULLmeans no value at all, not zero.- Find empty boxes with
IS NULL, full ones withIS NOT NULL. = NULLnever matches anything.
new words in your collection
- NULL
- IS NULL
This lesson isn’t saved. A free account remembers every lesson you finish.