The LIKE Operator
LIKE performs pattern matching with wildcards.
Wildcards
| Wildcard | Meaning |
|---|---|
% | Any sequence of characters |
_ | Any single character |
Names Starting With
sql
1-- Names starting with 'Al'
2SELECT * FROM students
3WHERE name LIKE 'Al%';Returns: Alice, Albert, Alex...
More Examples
sql
1-- Courses starting with 'Java'
2SELECT * FROM students
3WHERE course LIKE 'Java%';
4
5-- Names starting with 'M'
6SELECT * FROM students
7WHERE name LIKE 'M%';