The aim is to query all CITIES with both the starting and ending alphabet being a vowel. I tried the code below which doesn't seem to work. Can you explain why it doesn't work? Is there a better way?
I have tried to first get the cities which end in a vowel and then try to use it as a subquery for selecting cities that start in a vowel, as below
I have already tried implementing this code:
SELECT DISTINCT(CITY)
FROM STATION
WHERE CITY LIKE 'a%'
OR CITY LIKE 'e%'
OR CITY LIKE 'i%'
OR CITY LIKE 'o%'
OR CITY LIKE 'u%'
AND CITY IN (
SELECT DISTINCT(CITY)
FROM STATION
WHERE CITY LIKE '%a'
OR CITY LIKE '%e'
OR CITY LIKE '%i'
OR CITY LIKE '%o'
OR CITY LIKE '%u'
);
The needed output is something like:
Oslo
Upperco
Amazonia
...
...
...
I am getting these as output as well as those cities that don't end in a vowel like:
Arlington
Albany
Upperco
Aguanga
Odin
East China
Algonac
Onaway
Irvington
Arrowsmith
Oakfield
Elkton
East Irvine
Amo
...
...
...