SQL query to check if a name begins and ends with a vowel

后端 未结 25 1148
臣服心动
臣服心动 2020-11-30 23:16

I want to query the list of CITY names from the table STATION(id, city, longitude, latitude) which have vowels as both their first and last charact

25条回答
  •  囚心锁ツ
    2020-12-01 00:22

    Both of the statements below work in Microsoft SQL SERVER

    SELECT DISTINCT
        city
    FROM
        station
    WHERE
        SUBSTRING(lower(CITY), 1, 1) IN ('a', 'e', 'i', 'o', 'u')
        AND SUBSTRING(lower(CITY), LEN(CITY), 1) IN ('a', 'e', 'i', 'o', 'u');
    
    SELECT DISTINCT
        City
    FROM
        Station
    WHERE
        City LIKE '[A, E, O, U, I]%[A, E, O, U, I]'
    ORDER BY
        City;
    

提交回复
热议问题