Skip
Arish's avatar

44. Pattern Matching - Starts With


The LIKE Operator

LIKE performs pattern matching with wildcards.

Wildcards

WildcardMeaning
%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%';