Milky's note

[HackerRank](E) African Cities 본문

SQL/SQL 코딩 테스트-HackerRank

[HackerRank](E) African Cities

밀뿌 2022. 3. 25. 22:42

https://www.hackerrank.com/challenges/african-cities/problem?isFullScreen=true&h_r=next-challenge&h_v=zen 

 

African Cities | HackerRank

Query the names of all cities on the continent 'Africa'.

www.hackerrank.com

 

[문제]

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: 

 

 

[답]

- mysql

select city.name from city
join country
on CITY.CountryCode = COUNTRY.Code
where country.CONTINENT = 'Africa'

두 테이블을 join하는 문제이다.

조건 컬럼에서 country 테이블이 사용되고 조회 컬럼에서 city 테이블이 사용되므로 full join을 해준다.

Comments