[SOLVED] Select Names of city starting and ending with vowels from STATION table

Issue

Query the list of CITY names from STATION which have vowels (i.e., a, e, i, o, and u) as both their first and last characters. Your result cannot contain duplicates.

I tried to run this query but it is returning an empty output

/*
Enter your query here.
*/
SELECT DISTINCT CITY 
FROM STATION 
WHERE CITY LIKE '[aeiou]%[aeiou]';

Solution

The LIKE pattern you are using is an extension only supported by SQL Server (and Sybase). In MySQL, you can use regular expressions:

WHERE CITY REGEXP '^[aeiou].*[aeiou]$'

Answered By – Gordon Linoff

Answer Checked By – Terry (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published.