Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

regexp_like similar function in MySQL?

Tags:

regex

sql

mysql

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.

enter image description here

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')

like image 240
Prateek Joshi Avatar asked Mar 23 '16 10:03

Prateek Joshi


Video Answer


1 Answers

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)

like image 112
VoteyDisciple Avatar answered Sep 28 '22 22:09

VoteyDisciple