SQL 스터디/HackerRank

[해커랭크] MySQL 정규표현식 - Weather Observation Station 12

황금붕어빵 2023. 9. 11. 06:50

 

 

 


 

 

Weather Observation Station 12 | HackerRank

Query an alphabetically ordered list of CITY names not starting and ending with vowels.

www.hackerrank.com

이번 문제는 모음으로 시작하지 않고 모음으로 끝나지 않는 도시이름을 출력하는 문제입니다.

 

[Weather Observation Station 11] 문제와 다르게 이번엔 or 조건이 아닌 and 조건입니다.

문제)
Query the list of CITY names from STATION that do not start with vowels and do not end with vowels. Your result cannot contain duplicates.

출처 : 해커랭크

이번 문제는 아래와 같이 풀면 됩니다.

select distinct city
from station
where city regexp('^[^aeiou]')
and city regexp('[^aeiou]$')

정규표현식 내에서 and 조건은 따로 없는 것 같네요.. 그래서 정규표현식을 각각 작성하고 두 조건을 and 구문으로 연결하였습니다.