175. Combine Two Table

Leetcode 问题: 175. Combine Two Table

题目

PersonAddress 资料表,Person 不一定会有 Address

在不管有没有 Address 的条件捞取出 FirstName,LastName, City, State 栏位资料

Person 资料表

Column Name Type
PersonId int
FirstName varchar
LastName varchar

Address 资料表

Column Name Type
AddressId int
PersonId int
City varchar
State varchar

答案

# Write your MySQL query statement below
SELECT `FirstName`, `LastName`, `City`, `State`
FROM `Person`
    LEFT JOIN `Address` ON
    `Person`.`PersonId` = `Address`.`PersonId`

参考资料