SQL 스터디/HackerRank

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

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

 


 

Weather Observation Station 11 | HackerRank

Query a list of CITY names not starting or ending with vowels.

www.hackerrank.com

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

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

출처 : 해커랭크

기존에 사용했던 정규표현식을 그대로 활용하면 될 것 같습니다.

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

| : | 기호는 '또는' 이라는 의미를 가지고 있습니다.

 

모음으로 끝나지 않는 도시이름은 [^aeiou] 다음에 $ 표시를 해주면 됩니다.

 

모음으로 시작하지 않는 도시이름은 아래 링크를 참고해주시면 됩니다.

 

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

https://www.hackerrank.com/challenges/weather-observation-station-9/problem Weather Observation Station 9 | HackerRank Query an alphabetically ordered list of CITY names not starting with vowels. www.hackerrank.com 어김없이 SQL 정규표현식 문제

day-of-goldfish.tistory.com

^[^aeiou] 와 [^aeiou] 사이에 | 기호를 삽입하면 모음으로 시작하지 않거나 모음으로 끝나지 않는 도시이름을 출력하는 쿼리가 완성됩니다.