Skip to content

SQL Practice 6

1. 문제 [[object Object]]

각 환자의 이름, 성 및 전체 주 이름을 표시합니다.

예: 'ON' 대신 'Ontario'

patient_idfirst_namelast_namegenderbirth_datecityprovince_idallergiesheightweight
1DonaldWaterfieldM1963-02-12BarrieONNULL15665
2MickeyBaashaM1981-05-28DundasONSulfa18576
3JijiSharmaM1957-09-05HamiltonONPenicillin194106
4BlairDiazM1967-01-07HamiltonONNULL191104
5CharlesWolfeM2017-11-19OrilliaONPenicillin4710
6SueFalconF2017-09-30AjaxONPenicillin435

2. 정답

SELECT first_name, last_name, province_names.province_name
FROM patients, province_names
WHERE patients.province_id = province_names.province_id;

3. 다른 정답

SELECT first_name, last_name, province_name
FROM patients
JOIN province_names ON province_names.province_id = patients.province_id;

4. 결과

first_namelast_nameprovince_name
DonaldWaterfieldOntario
MickeyBaashaOntario
JijiSharmaOntario
BlairDiazOntario
CharlesWolfeOntario
SueFalconOntario

5. OUTER JOIN 관계 한 눈에 보기

OUTER JOIN

이미지 출처: SQL 기본 문법: JOIN(INNER, OUTER, CROSS, SELF JOIN)