
- 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
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)
- Related Articles
- Wildcard Pattern Matching
- Unix filename pattern matching in Python
- Pattern matching in C# with Regex
- Pattern matching in Python with Regex
- What is MySQL REGEXP operator and how it handles pattern matching?
- Unix filename pattern matching in Python (fnmatch)
- What is Pattern Matching in C# 7.0?
- Program to check regular expression pattern is matching with string or not in Python
- Lua pattern matching vs regular expression
- How can we create MySQL view by selecting data based on pattern matching from base table?
- Print all words matching a pattern in CamelCase Notation Dictionary in C++
- Program to check pattern of length m repeated K or more times exists or not in Python
- How to add two or more strings in MySQL?
- Biggest value from two or more fields in MySQL?
- Growing two or more crops in definite row pattern ismixed farmingmixed croppinginter-croppingcrop-rotation

Advertisements