Weather Observation Station 8
Last updated
Last updated
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.
Sol:
SELECT DISTINCT CITY FROM STATION
WHERE CITY REGEXP '^[AEIOU]' AND CITY REGEXP '[AEIOU]$';
Explanation:
REGEXP '^[AEIOU]': This condition in the WHERE clause checks if the CITY column starts with any of the specified vowels using the regular expression pattern ^[AEIOU].
^ denotes the start of the string.
[AEIOU] denotes a character class that matches any one character from the specified set of vowels ('A', 'E', 'I', 'O', 'U').
REGEXP '[AEIOU]$': This condition in the WHERE clause checks if the CITY column ends with any of the specified vowels using the regular expression pattern [AEIOU]$.
[AEIOU] denotes a character class that matches any one character from the specified set of vowels ('A', 'E', 'I', 'O', 'U').
$ denotes the end of the string.
So, the query selects cities where the city name both starts and ends with one of the specified vowels.