shashikant solanki
shashikant solanki

Reputation: 1

MySQL | Regular expressions (Regexp)

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

Input Format

The STATION table is described as follows:

station table

Select distinct city from station where city REGEXP '^[aeiou].'; In this query what does this '.' operator stands for "^[aeiou]." when i am removing this '.' i am getting wrong answer why is it so?

Upvotes: -4

Views: 298

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 520958

In the context of a regular expression, dot . means any single character. So ^[aeiou]. means match a city name which starts with a vowel, followed by any second character. You don't even need the dot here, and could just use:

SELECT DISTINCT city
FROM station
WHERE city REGEXP '^[aeiou]';

Upvotes: 0

Related Questions