sql · level 1 · unit 2 · lesson 2
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
goes inside . Numbers do not.
To find pets by species, you compare with text. Text in SQL goes inside single quotes, like 'cat'. The quotes show where the text starts and stops.
Numbers, like 3, need no quotes. Leave the quotes off text, though, and cat looks like a column name. The database goes looking for a column called cat.
Text must match exactly, so 'Cat' with a capital C finds nothing. Forget the closing quote and the text never ends, so you get unrecognized token.
SELECT name, age FROM pets WHERE species = 'cat'; Use single quotes ' round text in SQL, not double quotes.
guess first
The quotes have gone. What happens?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
SELECT name FROM pets WHERE species = dog;
your turn
Your turn. Round up the animals.
This table has dogs, cats, a fish and a rabbit. Type one species between the quotes, in small letters, then press run.
result
Your answer appears here as a table.
fix it
A quote has gone missing. Can you fix it?
result
Your answer appears here as a table.
- Read the error. It says
unrecognized token. What does that token start with? - Text needs a quote at both ends. Count the quotes around Luna.
- Add ' straight after Luna, before the semicolon, then press run.
nailed it
you found pets by name and species. :D
- Text goes inside single quotes, like
'cat'. - Numbers need no quotes.
no such columnnaming your text means the quotes are missing.
new words in your collection
- text
- single quotes
This lesson isn’t saved. A free account remembers every lesson you finish.