https://leetcode.com/problems/combine-two-tables/
해석:
Write an SQL query to report the first name,
last name, city, and state of each person in the Person table.
If the address of a personId is not
present in the Address table, report null instead.
|
cs |
firstName , lastName, city, state를 출력하라,
그러나 Address table에 personId가 없으면, null을 리턴하라는 내용입니다.
Person table과 Address table이 나오며 Null이 나오니, 두 테이블을 합쳐주며 없을 경우 null을 리턴하는
Join을 쉽게 생각할 수 있습니다.
SELECT P.firstName , P.lastName, A.city, A.state
FROM Person AS P
LEFT JOIN Address AS A ON P.personId = A.personId |
cs |
통과되었습니다.
'Leetcode' 카테고리의 다른 글
leetcode Reverse Integer (0) | 2022.05.29 |
---|---|
Add Two Numbers leetcode 2 (0) | 2022.05.29 |
[MySQL] 176. Second Highest Salary[LeetCode Medium] - 1 (0) | 2022.05.25 |
[MySQL] 175. Combine Two Tables [LeetCode Easy] (0) | 2022.05.25 |
[LeetCode Medium] 3. Longest Substring Without Repeating Characters [C/C++] (0) | 2022.05.25 |