
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Find String of Specified Pattern in Another String Using MySQL
We can find a string of specified pattern within another string by using LIKE operator along with WILDCARDS.
Syntax
LIKE specific_pattern
Specific_pattern is the pattern of string we want to find out within another string.
Example
Suppose we have a table named ‘student’ having names of the students and we want to get the details of all those students which are having the pattern of string ‘av’ within their names. It can be done with the help of 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 a WILDCARD used along with LIKE operator.
Advertisements