- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How it is possible in MySQL to find a string of specified pattern within another string?
We can find a string of specified pattern within another string by using LIKE operator along with WILDCARDS.
Specific_pattern is the pattern of string we want to find out within another string.
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.
- Related Articles
- In MySQL, how can we check whether a string of a specified pattern is not present within another string?
- How can it be possible to invert a string in MySQL?
- How to check index within a string of a specified substring in JSP?
- How is it possible in MySQL to find the location of the first occurrence of a substring in a string?
- Check if it is possible to transform one string to another in Python
- How can we replace all the occurrences of a substring with another substring within a string in MySQL?
- In MySQL, how can we pad a string with another string?
- How to replicate a string for a specified number of times in MySQL?
- Check if it is possible to convert one string into another with given constraints in Python
- How to check if a string is a subset of another string in R?
- Print all possible ways to convert one string into another string in C++
- How can we retrieve the length of a specified string in MySQL?
- Is it possible to synchronize the string type in Java?
- How to insert a string in beginning of another string in java?