SQL Like
The SQL LIKE is used to return lines if the operand matches a pattern in a select query.
Like syntax
SELECT * FROM table_name WHERE column_name LIKE pattern;
Like example
Coder books table
| ID |
Title |
Price |
Description |
| 1 |
Learn SQL |
20 |
Learn SQL language |
| 2 |
Learn MySQL |
22 |
Learn MySQL language |
| 3 |
HTML book |
17 |
Learn HTML |
| 4 |
Learn PHP |
20 |
Introduction to PHP |
| 5 |
Learn PHP |
20 |
PHP course |
select * from coder_books where title LIKE '%PHP%';
Result
| ID |
Title |
Price |
Description |
| 4 |
Learn PHP |
20 |
Introduction to PHP |
| 5 |
Learn PHP |
20 |
PHP course |
select * from coder_books where description LIKE 'Learn%';
Result
| ID |
Title |
Price |
Description |
| 1 |
Learn SQL |
20 |
Learn SQL language |
| 2 |
Learn MySQL |
22 |
Learn MySQL language |
| 3 |
HTML book |
17 |
Learn HTML |
select * from coder_books where price LIKE '17';
Result
| ID |
Title |
Price |
Description |
| 3 |
HTML book |
17 |
Learn HTML |