mysqlsql

Query the list of CITY names starting with vowels (i.e., a, e, i, o, or u) from STATION. Your result cannot contain duplicates


SELECT DISTINCT(CITY) FROM STATION WHERE CITY LIKE '[AEOIU]%';

Why this query is not working?


Solution

  • Another ways:

    SELECT * from STATION where FIND_IN_SET(left(CITY,1),'A,E,I,O,U')>0;
    

    And

    select distinct CITY from STATION where substring(CITY,1,1) in
    ('A','E','I','O','U');