![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
MySQL pattern matching 3 or more “a's” in name?
Following is the syntax −
select * from yourTableName where yourColumnName like '%a%a%a%';
Let us first create a −
mysql> create table DemoTable1393 -> ( -> CountryName varchar(40) -> ); Query OK, 0 rows affected (0.71 sec)
Insert some records in the table using insert −
mysql> insert into DemoTable1393 values('andorra'); Query OK, 1 row affected (0.50 sec) mysql> insert into DemoTable1393 values('australia'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1393 values('argentina'); Query OK, 1 row affected (0.46 sec) mysql> insert into DemoTable1393 values('austria'); Query OK, 1 row affected (0.26 sec)
Display all records from the table using select −
mysql> select * from DemoTable1393;
This will produce the following output −
+-------------+ | CountryName | +-------------+ | andorra | | australia | | argentina | | austria | +-------------+ 4 rows in set (0.00 sec)
Following is the query to pattern matching 3 or more “a's” in column −
mysql> select * from DemoTable1393 where CountryName like '%a%a%a%';
This will produce the following output −
+-------------+ | CountryName | +-------------+ | australia | +-------------+ 1 row in set (0.00 sec)
Advertisements