I was trying to solve a problem in SQL and I came across the problem:
Query the list of CITY
names from STATION
table that do not start with vowels. Your result cannot contain duplicates.
I used regexp_like()
function using Oracle but how I can query the results using MySQL?
In Oracle I did regexp_like(city, '^[^aeiou]', 'i')
MySQL has a REGEXP
keyword for just such an occasion.
SELECT ...
FROM ...
WHERE field REGEXP 'expression';
See: http://dev.mysql.com/doc/refman/5.7/en/regexp.html (first Google result for MySQL REGEXP)
Select distinct City
from Station
where Left(Upper(city),1))
not like '%[AEIOU]%'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.