SQL Like

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

IDTitlePriceDescription
1Learn SQL20Learn SQL language
2Learn MySQL22Learn MySQL language
3HTML book17Learn HTML
4Learn PHP20Introduction to PHP
5Learn PHP20PHP course
select * from coder_books where title LIKE '%PHP%';

Result

IDTitlePriceDescription
4Learn PHP20Introduction to PHP
5Learn PHP20PHP course
select * from coder_books where description LIKE 'Learn%';

Result

IDTitlePriceDescription
1Learn SQL20Learn SQL language
2Learn MySQL22Learn MySQL language
3HTML book17Learn HTML
select * from coder_books where price LIKE '17';

Result

IDTitlePriceDescription
3HTML book17Learn HTML