问题描述
https://leetcode.com/problems/combine-two-tables/
解决思路
用left join的方式,以tb1.PersonID = tb2.PersonID为条件,将两表join到一起,并且select出特定的行即可。
代码
# Write your MySQL query statement below
SELECT tb1.FirstName, tb1.LastName, tb2.City, tb2.State #select specific rows in two tables
FROM Person as tb1 #rename the table
LEFT JOIN Address as tb2 #return all row in the left table(tb1)
on tb1.PersonID = tb2.PersonID; #the conditions of left join