← ACARA Digital Technologies Years 7–8

SQL LIKE with the % wildcard

LIKE in a WHERE clause matches part of a text value. The % wildcard stands for any characters, so '%at%' finds text containing at, 'S%' starts with S and '%s' ends with s.

Understanding SQL LIKE with the % wildcard in ACARA Digital Technologies Years 7–8

What it does: A % on both sides of at means any characters can come before and after it, so at can be anywhere in the name. A% means A comes first, then any characters. '%A' would find names that END with A. % can match many characters, one character, or even no characters at all. The LIKE pattern is text, so it must be inside quotes: 'P%'. Smith starts with S. Ross only ends with s, so it would match '%s' instead. Football contains the letters at in the middle (footb-a-ll has no at; check: f-o-o-t-b-a-l-l). Pencil has no at either. The = operator only matches the whole value exactly. LIKE lets % stand for any characters.

Common mistakes: Without the % wildcard, LIKE 'P' only matches a name that is exactly P. To find names that start with P, write LIKE 'P%'. The fields in a SELECT list must be separated by a comma. It should be SELECT name, price.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 365–411) and word search (Modules 331–411).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which query finds students whose first name starts with the letter A?
SELECT * FROM students WHERE firstName LIKE 'A%';SELECT * FROM students WHERE firstName LIKE '%A';
Matches
SELECT * FROM students WHERE firstName = 'A%';
↓
The = operator looks for the exact text A%, so the wildcard does not work. It should be LIKE 'A%'.
Applying
Meanings
Term
LIKE '%at%'
Meaning
LIKE in a WHERE clause matches part of a text value. The % wildcard stands for any characters, so '%at%' finds text containing at, 'S%' starts with S and '%s' ends with s.
Practice
SELECT name, price
Testing
Gaps
WHERE firstName 'A%';
Check Answer
Spots
3WHERE stock > 0
4AND name LIKE 'P';

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Sand Cat' badge — Precision Prowler, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which query finds students whose first name starts with the letter A?
A. SELECT * FROM students WHERE firstName LIKE 'A%'; ✓
B. SELECT * FROM students WHERE firstName LIKE '%A';
A% means A comes first, then any characters. '%A' would find names that END with A.
2. What does LIKE '%s' find in a text field?
A. Text that ends with s ✓
B. Text that starts with s
The % comes first and stands for any characters, so the s must be the last letter.
3. Which pattern finds product names that contain the letters at anywhere?
A. LIKE 'at'
B. LIKE '%at%' ✓
A % on both sides allows any characters before and after at. Without %, LIKE 'at' only matches the exact text at.
4. True or false: the % wildcard can stand for any number of characters.
A. False
B. True ✓
% can match many characters, one character, or even no characters at all.
5. Which query is written correctly?
A. SELECT name FROM products WHERE name LIKE 'P%'; ✓
B. SELECT name FROM products WHERE name LIKE P%;
The LIKE pattern is text, so it must be inside quotes: 'P%'.

Match the Pairs

WHERE lastName LIKE 'S%' → Finds students whose last name starts with S, because % stands for any characters after the S
WHERE name LIKE '%s' → Finds products whose name ends with s, because % stands for any characters before the s
Find products whose name contains the letters at anywhere in the text → SELECT name FROM products WHERE name LIKE '%at%';
Find students whose first name starts with L → SELECT firstName FROM students WHERE firstName LIKE 'L%';
SELECT * FROM students WHERE firstName = 'A%'; → The = operator looks for the exact text A%, so the wildcard does not work. It should be LIKE 'A%'.
SELECT name FROM products WHERE name LIKE %at%; → The pattern is missing its quote marks. It should be LIKE '%at%'.

Key Term

LIKE '%at%'
LIKE in a WHERE clause matches part of a text value. The % wildcard stands for any characters, so '%at%' finds text containing at, 'S%' starts with S and '%s' ends with s.

Fill in the Blanks

1. SELECT firstName FROM students WHERE firstName LIKE 'A%';
Hint: Type the keyword that compares a text value to a pattern.
2. SELECT name FROM products WHERE name LIKE 'P%';
Hint: Type the wildcard symbol that stands for any characters after the P.
3. SELECT name FROM products WHERE name LIKE '%s';
Hint: Type the wildcard symbol so any characters can come before the final letter.
4. SELECT name FROM products WHERE name LIKE '%at%';
Hint: Type the field whose text is being searched for the pattern.
5. SELECT name FROM products WHERE name LIKE 'P%';
Hint: Type the clause keyword that filters records before LIKE is used.

Spot the Error

Question 1
A SELECT name, price
B FROM products
C WHERE stock > 0
D AND name LIKE 'P';
Line D — Without the % wildcard, LIKE 'P' only matches a name that is exactly P. To find names that start with P, write LIKE 'P%'.
Question 2
A SELECT name price
B FROM products
C WHERE name LIKE '%ball'
D ORDER BY price;
Line A — The fields in a SELECT list must be separated by a comma. It should be SELECT name, price.
Question 3
A SELECT firstName,
B FROM students
C WHERE firstName LIKE 'S%';
Line A — There must be no comma after the last field in the SELECT list. A trailing comma makes the query fail. It should be SELECT firstName.
Question 4
A SELECT name FROM products
B WHERE name IS '%s'
C ORDER BY name;
Line B — Pattern matching needs the LIKE keyword. IS cannot be used with the % wildcard. It should be WHERE name LIKE '%s'.
Question 5
A SELECT firstName, house
B FROM students
C WHERE house = 'R%'
D ORDER BY firstName;
Line C — The = operator looks for the exact text R%, so the % is not treated as a wildcard. Use LIKE: WHERE house LIKE 'R%'.

Student with a class code? Join your class →