LIKE
SQL · Unit 2: Filtering
- Full plan
- SQL
- 11 exercises
Someone calls the store: I want that thing that starts with M, I can't remember what it's called. = is no help, because no product is named M.
LIKE compares against a pattern, and inside the pattern % stands for any text. 'M%' is an M and then anything. '%e' is anything and then an e at the end.
SELECT name
FROM products
WHERE name LIKE 'M%';Returns
| name |
|---|
| Mouse |
| Monitor |
The rest of the explanation is in the lesson, which is part of the full plan.
Exercises in this lesson
You do them in the app, which checks them on the spot and explains why.
1. Complete the code
In the store's search box, someone has typed
Heaand is waiting for suggestions. Fill in the blank with the pattern for what starts that way.2. Predict the output
Now the
%goes in front. What does this query return?3. Predict the output
What does this query return?
4. Find the bug
The search box should show everything with
lein its name that costs 400 or less, which is two products. Only the Cable comes up. Which line has the problem?5. Put the lines in order
Someone types
Ain the category filter, and the search box shows the products of every category that starts that way. Put the query in order. Two lines don't belong.6. Predict the output
This pattern uses both wildcards. What does the query return?
7. Multiple choice
The dates in
orderslook like this:2026-01-09. Which condition returns only the orders from the first nine days of January, the 01 through the 09?8. Predict the output
Someone searches with caps lock on. What does this query return here?
9. Complete the code
At the counter, someone looks up a customer by name, typing in lowercase and without accents, and wants to find Chloë. Fill in the blank with the pattern that does find her.
10. Put the lines in order
Someone looks through the customers over 40 and types the letter
ein the search box. Put the query in order. One line doesn't belong.11. Write the code
A package arrived with a torn label. All you can read is that the name ends in
nand the city starts withBo. Write a query that shows thenameand thecity, in that order, of whoever fits both clues.
It opens in your browser. This lesson is part of the full plan; the first unit of each course is free.