• Teach Your Self With
             w3htmlschool.com

MySQL LIKE Operator

The mysql LIKE operator is used for select data based on patterns or in other words comparison based on wildcards . Using the LIKE operator in the right way is important to increase the query performance in a SELECT, INSERT, UPDATE, or DELETE statement.

Syntax


SELECT * FROM table_name
WHERE COLUMN NAME
LIKE (pattern)
Table
+-------------+----------+
| Field | Type |
+-------------+----------+
| ID | int(11) |
| Name | char(35) |
| CountryCode | char(3) |
| District | char(20) |
| Population | int(11) |
+-------------+----------+
Example
select name from city where name like('A%');
Output
+-------------------+
| name |
+-------------------+
| Amsterdam |
| Apeldoorn |
| Almere |
| Arnhem |
| ´s-Hertogenbosch |
| Amersfoort |
| Alkmaar |
| Alger |
| Annaba |
+-------------------+
9 rows in set (0.07 sec)