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)

Updated on: 22-Aug-2019

70 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements