1. 문제
Given the CITY and COUNTRY tables, query the names of all cities where the CONTINENT is 'Africa'.
Note: CITY.CountryCode and COUNTRY.Code are matching key columns.
Input Format
The CITY and COUNTRY tables are described as follows:
2. 답
SELECT city.name
FROM city
INNER JOIN country ON city.countrycode = country.code
WHERE country.continent = 'Africa'
3. KEY POINT
- INNER JOIN : 양쪽 테이블에 모두 정보가 있는 데이터를 합침
- ON 뒤에는 JOIN 할 때의 조건
- 테이블의 컬럼명이 겹치는 경우, 모호성 분명히 해주기 위해 컬럼명 앞에 테이블 이름 붙이기
www.hackerrank.com/challenges/african-cities/problem?h_r=internal-search
'MySQL > 문제풀이' 카테고리의 다른 글
[LeetCode] Self JOIN : 181. Employees Earning More Than Their Managers (0) | 2021.03.15 |
---|---|
[LeetCode] LEFT JOIN : 183. Customers Who Never Order (0) | 2021.03.15 |
[HackerRank] INNER JOIN : Average Population of Each Continent (0) | 2021.03.15 |
[HackerRank] INNER JOIN : Asian Population (0) | 2021.03.15 |
[HackerRank] CASE : Type of Triangle (0) | 2021.03.15 |
댓글