Match text patterns with LIKE
Question
Show the name of every employee whose name starts with the letter L.
employeesid, name, salary, department_id, manager_id, hired_on
departmentsid, name, city
Your query
Ctrl+Enter to run
Result
Expected result
| name |
|---|
| Lucas Moreau |
| Liam Walsh |
Hint
In LIKE, % stands for "any characters".
Show the solution
solution.sql
Run this code
SELECT name
FROM employees
WHERE name LIKE 'L%';
Why it works
'L%' means: an L, then anything. In SQLite, LIKE ignores the case of ASCII letters, so 'l%' would find the same two people.
Common mistake
Writing WHERE name = 'L%' looks for a name that is literally L followed by a percent sign, and finds nothing. Patterns only work with LIKE.