Lesson 17 of 30
57%
LIKE and Wildcards
LIKE matches a pattern in text.
Percent % means any number of characters.
Underscore _ means exactly one character.
Starts with
sql
Result
| name |
|---|
| Ada |
1 row
Ends with
sql
Result
| name |
|---|
| Ada |
| Nia |
2 rows
Contains
sql
Result
| name | city |
|---|---|
| Ada | London |
1 row
One letter hole
S_m matches Sam but not Slam.
sql
Result
| name |
|---|
| Sam |
1 row
NOT LIKE
sql
Result
| name |
|---|
| Sam |
| Lin |
| Omar |
| Nia |
4 rows
Tip: LIKE is case-insensitive for most MySQL text collations. Test yours if it matters.
Test yourself
Three quick questions made just for this lesson. Earn 10 XP per correct answer.