sql · level 1 · unit 3 · lesson 4
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
finds text that fits a .
= needs an exact match. LIKE is looser: it checks whether text fits a pattern. Patterns use the %, which stands for any letters at all, or none.
'The%' means starts with The. '%Cats' means ends with Cats. '%of%' means has of somewhere inside. The pattern still goes in single quotes.
LIKE does not mind capitals, so 'the%' finds The Last Biscuit too.
SELECT title FROM films WHERE title LIKE 'The%'; A pattern with no % must match the whole text, a lot like =.
guess first
The % comes first. Which films match?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
SELECT title FROM films WHERE title LIKE '%s';
your turn
Your turn. Search the pet names.
Type a letter between the quotes, before the %. The query finds every pet whose name starts with it. Try B or L.
result
Your answer appears here as a table.
fix it
No dragon found? Fix the pattern.
result
Your answer appears here as a table.
- Without a wildcard,
LIKEneeds the whole title to match. Is any film called only Dragon? - The film is called The Sleepy Dragon. Some words come before Dragon.
- Put % before Dragon inside the quotes, so it reads '%Dragon', then press run.
nailed it
you searched with patterns. :D
LIKEchecks whether text fits a pattern.%stands for any letters, or none at all.LIKEdoes not mind capital letters.
new words in your collection
- LIKE
- pattern
- wildcard
This lesson isn’t saved. A free account remembers every lesson you finish.