By using the LIKE operator and wildcard characters, we can find a string with a specified pattern in another string.
LIKE specific_pattern
Specific_pattern is the string pattern we want to find within another string.
Suppose we have a table called "student" which contains the names of students and we want to get the details of all students whose names contain the string "av" pattern . This can be done with the help of the following MySQL query -
mysql> Select * from Student Where Name LIKE '%av%'; +------+--------+---------+-----------+ | Id | Name | Address | Subject | +------+--------+---------+-----------+ | 1 | Gaurav | Delhi | Computers | | 2 | Aarav | Mumbai | History | | 20 | Gaurav | Jaipur | Computers | +------+--------+---------+-----------+ 3 rows in set (0.00 sec)
In the above example, the '%' symbol is the wildcard character used with the LIKE operator.
The above is the detailed content of MySQL How to find a string with a specified pattern within another string?. For more information, please follow other related articles on the PHP Chinese website!