Skip
Arish's avatar

46. Pattern Matching - Contains


Containing a Pattern

Use % on both sides.

Syntax

sql
1SELECT * FROM students
2WHERE name LIKE '%ar%';

Returns names containing 'ar': Carol, Mark, Sarah...

Examples

sql
1-- Names containing 'li'
2SELECT * FROM students
3WHERE name LIKE '%li%';
4
5-- Courses containing 'on'
6SELECT * FROM students
7WHERE course LIKE '%on%';