You are viewing a single comment's thread. Return to all comments →
Approach - 1 (REGEXP)
SELECT DISTINCT CITY FROM STATION WHERE CITY NOT REGEXP '^[aeiou]'
Approach - 2 (SUBSTRING)
SELECT DISTINCT CITY FROM STATION WHERE SUBSTRING(CITY, 1, 1) NOT IN ('a', 'e', 'i', 'o', 'u')
Approach - 3 (LEFT FUNCTION)
SELECT DISTINCT CITY FROM STATION WHERE LEFT(CITY, 1) NOT IN ('a', 'e', 'i', 'o', 'u')
Approach - 4 (LIKE OPERATOR)
SELECT DISTINCT CITY FROM STATION WHERE CITY NOT LIKE 'a%' AND CITY NOT LIKE 'e%' AND CITY NOT LIKE 'i%' AND CITY NOT LIKE 'o%' AND CITY NOT LIKE 'u%'
P.S. All above operators (IN, LIKE, REGEXP) used are case insensitive, so no need to write 'a' and 'A', simply 'a' will do the work for both the cases
Upvote if it helped :)
Seems like cookies are disabled on this browser, please enable them to open this website
Weather Observation Station 9
You are viewing a single comment's thread. Return to all comments →
Approach - 1 (REGEXP)
SELECT DISTINCT CITY FROM STATION WHERE CITY NOT REGEXP '^[aeiou]'
Approach - 2 (SUBSTRING)
SELECT DISTINCT CITY FROM STATION WHERE SUBSTRING(CITY, 1, 1) NOT IN ('a', 'e', 'i', 'o', 'u')
Approach - 3 (LEFT FUNCTION)
SELECT DISTINCT CITY FROM STATION WHERE LEFT(CITY, 1) NOT IN ('a', 'e', 'i', 'o', 'u')
Approach - 4 (LIKE OPERATOR)
SELECT DISTINCT CITY FROM STATION WHERE CITY NOT LIKE 'a%' AND CITY NOT LIKE 'e%' AND CITY NOT LIKE 'i%' AND CITY NOT LIKE 'o%' AND CITY NOT LIKE 'u%'
P.S. All above operators (IN, LIKE, REGEXP) used are case insensitive, so no need to write 'a' and 'A', simply 'a' will do the work for both the cases
Upvote if it helped :)