You only remember the start
A pupil asks for "the chee-something". It could be a cheese roll or a cheese toastie.
You cannot test for an exact name you do not know. A pattern can stand for many names at once.
Key words
| Word | What it means |
|---|---|
| Database | an organised store of tables that you can ask questions |
| LIKE | tests whether text matches a pattern |
| Pattern | text with wildcards that stands for many possible words |
| Wildcard | a special mark that stands for other characters |
| Many-character wildcard | the symbol `%`: any number of characters, even none |
| One-character wildcard | the symbol `_`: exactly one character |
| Character | one letter, digit, space or symbol |
The cells students fill in are left blank in this preview.
By the end of this lesson
Note
I can write a LIKE test with the two wildcards to find text that starts, ends or contains something.
Starter
Have a go
Starter
3 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.
The two wildcards
| Wildcard | Stands for | Pattern | Matches |
|---|---|---|---|
| `%` | Any number of characters, even none | `'C%'` | Any name that starts with C |
| `%` | Any number of characters, even none | `'%e'` | Any name that ends with e |
| `%` | Any number of characters, even none | `'%ee%'` | Any name with ee inside |
| `_` | Exactly one character | `'_ola'` | Cola, and any other four-letter name ending ola |
The cells students fill in are left blank in this preview.
Try it: three patterns
SELECT name FROM products WHERE name LIKE 'C%';
SELECT name FROM products WHERE name LIKE '%ee%';
SELECT name FROM products WHERE name LIKE '_o%';
-- Try 'A%' and then '%s'.
Capital letters and NOT LIKE
In SQLite, LIKE ignores capital letters for English letters, so 'c%' and 'C%' match the same names. Other database products can be strict about case, so check.
Put NOT in front to find the names that do not match: name NOT LIKE 'C%'.
Try it: the underscore on dates
-- Dates saved as text can be matched too.
SELECT sale_id, sale_day FROM sales WHERE sale_day LIKE '2026-09-1_';
SELECT sale_id, sale_day FROM sales WHERE sale_day LIKE '2026-09-0%';
Check
Have a go
Check
4 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.