Skip to content
Advertisement

In SQL I want to display the names of all those cities which end with an vowel

I wrote the following query

SELECT UNIQUE 
    CITY 
FROM 
    STATION 
WHERE 
    (CITY LIKE '%A' OR 
     CITY LIKE '%E' OR 
     CITY LIKE '%I' OR 
     CITY LIKE '%O' OR 
     CITY LIKE '%U') 
ORDER BY 
    CITY;

What is wrong with this?

Advertisement

Answer

If you want it to work with lower/upper letters, you could use UPPER(CITY), otherwise it’s all good.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement