Leet) No.175 [Combine Two Tables]
본문 바로가기
Data Base/Leetcode

Leet) No.175 [Combine Two Tables]

by 조훈이 2021. 8. 31.

Leetcode No.175 [Combine Two Tables]


  문제 

Combine Two Tables - LeetCode

 

Combine Two Tables - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com


  설명 

 

  두 테이블 에서 Person 테이블에 있는 모든 사람들에 대해서 새로운 테이블을 만들어야 한다. Address 의 PK 인 AddressId 와는 상관없이 만들으라고 했으므로 결국 Person 테이블에만 존재하는 사람이거나, 두 테이블 모두 존재하는 사람에 대해서 테이블을 만들어야 하므로 LEFT JOIN 을 하면 되는 것 이다.


  Code 

더보기
SELECT Person.FirstName, Person.LastName, Address.City, Address.State
FROM Person
LEFT JOIN Address
    ON Person.PersonID = Address.PersonID;
728x90

'Data Base > Leetcode' 카테고리의 다른 글

Leetcode) No.262 [Trips and Users]  (0) 2022.04.04
Leetcode) No.626 [Exchange Seats]  (0) 2021.09.04
Leetcode) No.180 [Consecutive Numbers]  (0) 2021.09.03
Leet) No.1179 [Reformat Department Table]  (0) 2021.08.30

댓글