LeetCode - 175. Combine Two Tables (MySQL)

조민수·2024년 6월 2일
0

LeetCode

목록 보기
1/61

Easy, SQL - LEFT JOIN

RunTime : 768 ms


문제

Write a solution 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.

Return the result table in any order.

The result format is in the following example.


풀이

  • LeetCode 첫 풀이
  • EASY 부터 LEFT JOIN 문제라 조금 당황했다.
  • order에 대한 조건이 없다.
SELECT p.firstName, p.lastName, a.city, a.state
FROM Person as p LEFT JOIN Address as a ON p.personId = a.person
profile
사람을 좋아하는 Front-End 개발자

0개의 댓글