- 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
Retrieve records whenever a column value starts with 2 vowel letters in MySQL
Let us first create a table −
mysql> create table DemoTable664 (CityName varchar(100)); Query OK, 0 rows affected (0.89 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable664 values('Springfield'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable664 values('Austin'); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable664 values('Franklin'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable664 values('OAKLAND'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable664 values('Anchorage'); Query OK, 1 row affected (0.18 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable664;
This will produce the following output −
+-------------+ | CityName | +-------------+ | Springfield | | Austin | | Franklin | | OAKLAND | | Anchorage | +-------------+ 5 rows in set (0.00 sec)
Here is the query to use RLIKE/REGEXP pattern and display records whenever a column value starts with 2 vowel letters −
mysql> select *from DemoTable664 where CityName RLIKE '^[aeiouAEIOU][aeiouAEIOU]';
This will produce the following output −
+----------+ | CityName | +----------+ | Austin | | OAKLAND | +----------+ 2 rows in set (0.00 sec)
Advertisements