The LIKE operator is used to search a string using the percent sign (‘%’) and the underscore (‘_’).
Course table
COURSE_ID |
NAME |
DESCRIPTION |
DURATION |
PRICE |
1 |
SQL 1 |
SQL course for beginners |
1 week |
10 |
2 |
SQL 2 |
SQL course for advanced |
2 week |
50 |
3 |
HTML5 |
Learn HTML 5 |
1 week |
10 |
4 |
PHP |
PHP course |
4 week |
75 |
5 |
CSS |
Learn CSS |
2 week |
20 |
Like example
SELECT * FROM course WHERE description LIKE 'Lea%';
Output
COURSE_ID |
NAME |
DESCRIPTION |
DURATION |
PRICE |
3 |
HTML5 |
Learn HTML 5 |
1 week |
10 |
5 |
CSS |
Learn CSS |
2 week |
20 |
SELECT * FROM course WHERE description LIKE '%course%';
Output
COURSE_ID |
NAME |
DESCRIPTION |
DURATION |
PRICE |
1 |
SQL 1 |
SQL course for beginners |
1 week |
10 |
2 |
SQL 2 |
SQL course for advanced |
2 week |
50 |
4 |
PHP |
PHP course |
4 week |
75 |
SELECT * FROM course WHERE duration LIKE '%ek';
Output
COURSE_ID |
NAME |
DESCRIPTION |
DURATION |
PRICE |
1 |
SQL 1 |
SQL course for beginners |
1 week |
10 |
3 |
HTML5 |
Learn HTML 5 |
1 week |
10 |