SQL LIKE Operator
LIKE matches text against a pattern. % stands for any number of characters, and _ stands for exactly one.
Updated December 1, 2026
Syntax
WHERE column LIKE 'pattern'
Ends with
Every drink whose name ends in “Latte”.
SELECT name
FROM drinks
WHERE name LIKE '%Latte';
| name |
|---|
| Latte |
| Matcha Latte |
| Chai Latte |
Starts with
Names that start with C.
SELECT name
FROM drinks
WHERE name LIKE 'C%';
| name |
|---|
| Cappuccino |
| Cold Brew |
| Chai Latte |
Contains, and single-character wildcards
%o% finds an “o” anywhere. _ matches exactly one character, so '_e%' means “second letter is e”.
SELECT name
FROM drinks
WHERE name LIKE '_e%';
| name |
|---|
| Peppermint Tea |
| Lemonade |
Common mistakes
- Forgetting the
%:LIKE 'Latte'only matches the exact text. - Case sensitivity varies: SQLite and MySQL ignore case by default for English letters; PostgreSQL doesn’t (use
ILIKEthere). - A pattern starting with
%can’t use a normal index, so it’s slow on very large tables.
Practice LIKE Operator interactively
Write real queries in your browser and get instant feedback in the lesson “IN, BETWEEN, LIKE” (Unit 2). New learners can start free from the first lesson.
Frequently asked questions
How do I search for a literal % or _?
Escape it: LIKE '%50!%%' ESCAPE '!' finds text containing “50%”.
Is there regex in SQL?
Many databases add it: ~ in PostgreSQL, REGEXP in MySQL. LIKE is the portable option.