用于检查名称是否以元音开头和结尾的 SQL 查询
我想从表 STATION(id, city, longitude, latitude)
中查询 CITY
名称的列表,这些名称的第一个和最后一个字符都是元音.结果不能包含重复项.
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 characters. The result cannot contain duplicates.
为此,我写了一个类似 WHERE NAME LIKE 'a%'
的查询,它有 25 个条件,每个元音对应其他每个元音,这非常笨拙.有没有更好的方法?
For this is I wrote a query like WHERE NAME LIKE 'a%'
that had 25 conditions, each vowel for every other vowel, which is quite unwieldy. Is there a better way to do it?
推荐答案
您可以使用 正则表达式:
SELECT DISTINCT city
FROM station
WHERE city RLIKE '^[aeiouAEIOU].*[aeiouAEIOU]$'
相关文章