2022/12/20

LeetCode 175. Combine Two Tables

問題:如何讓兩個Tables能輸出成他所想要的

解法:關鍵在兩個Table都擁有personId欄位,將兩個Table欄位的personId JOIN就可以了,再輸出如需求的欄位即可
SELECT p.firstName, p.lastName, a.city, a.state
FROM Person AS p
         LEFT JOIN Address AS a ON p.personId = a.personId;