본문 바로가기
Algorithm & SQL/SQL

African Cities - BASIC JOIN

by YoonJong 2022. 6. 9.
728x90

이전 문제와 푸는 방법은 비슷하다.

혼자 복습할 수 있는 문제였다.

 

문제를 풀때, 테이블이 어떤 key로 이어져있는지 확인하고 inner join 을 이용해서 country의 continent 값이 africa 인 city 이름을 모두 출력하면 되는 문제였다.


 

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: 

 

정답 : 

select city.name
from city
inner join country
on city.countrycode = country.code
where country.continent = 'africa'

 

728x90

'Algorithm & SQL > SQL' 카테고리의 다른 글

SQL 예제  (0) 2022.06.28
Average Population of Each Continent - BASIC JOIN  (0) 2022.06.09
Population Census - BASIC JOIN  (0) 2022.06.09
Weather Observation Station 10  (0) 2022.06.09
Weather Observation Station 9  (0) 2022.06.08

댓글