

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
How to perform string matching in MySQL?
For string matching, use LIKE operator. Let us first create a table −
mysql> create table DemoTable -> ( -> MonthName varchar(100) -> ); Query OK, 0 rows affected (0.63 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('JFMA'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('JMA'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('JDN'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('JFOSA'); Query OK, 1 row affected (0.19 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
+-----------+ | MonthName | +-----------+ | JFMA | | JMA | | JDN | | JFOSA | +-----------+ 4 rows in set (0.00 sec)
Following is the query to perform string matching in MySQL −
mysql> select *from DemoTable WHERE MonthName LIKE '%J%M%';
Output
+-----------+ | MonthName | +-----------+ | JFMA | | JMA | +-----------+ 2 rows in set (0.00 sec)
- Related Questions & Answers
- C++ Program to Perform String Matching Using String Library
- How to perform Multiline matching with JavaScript RegExp?
- How to perform Case Insensitive matching with JavaScript RegExp?
- How MySQL can perform case-sensitive string comparison?
- How to perform Increment in MySQL Update?
- How to perform string aggregation/concatenation in Oracle?
- Wildcard matching of string JavaScript
- How to perform SELECT using COUNT in MySQL?
- MySQL query not matching due to punctuation?
- C++ Program to Implement String Matching Using Vectors
- Program to perform string compression in Python
- How to perform conditional GROUP BY in MySQL to fetch?
- C++ Program to Implement Bitap Algorithm for String Matching
- Perform custom sorting in MySQL
- How to perform custom sort by field value in MySQL?
Advertisements