반응형
문제
Query the list of CITY names from STATION that do not start with vowels. Your result cannot contain duplicates.
Input Format
The STATION table is described as follows:

where LAT_N is the northern latitude and LONG_W is the western longitude.
풀이
-- LEFT
SELECT DISTINCT CITY
FROM STATION
WHERE LEFT(CITY, 1) NOT IN ('a', 'e', 'i', 'o', 'u');
-- REGEXP
SELECT DISTINCT CITY
FROM STATION
WHERE CITY REGEXP "^[^aeiou]";
-- LIKE
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%';
배운점
추가 조건 작성 시, 칼럼 다시 적는거 잊지 말기!
WHERE 칼럼 NOT LIKE '조건'
AND 칼럼 NOT LIKE '조건'
...
반응형