[LeetCode] Combine Two Tables

Problem

Table: Person

Column NameType
PersonIdint
FirstNamevarchar
LastNamevarchar

PersonId is the primary key column for this table.
Table: Address

Column NameType
AddressIdint
PersonIdint
Cityvarchar
Statevarchar

AddressId is the primary key column for this table.

Write a SQL query for a report that provides the following information for each person in the Person table, regardless if there is an address for each of those people:

FirstName, LastName, City, State

Solution

select FirstName, LastName, City, State from Person left outer join Address on Person.PersonId = Address.PersonId;
    原文作者:linspiration
    原文地址: https://segmentfault.com/a/1190000014411304
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞