leetcode175 组合两个表 Combine Two Tables

创建表和数据:

drop table Person; 
Create table Person (PersonId int,FirstName varchar(255), LastName varchar(255));

drop table Address;
Create table Address (AddressId int,PersonId int, City varchar(255), State varchar(255));

insert into Person (PersonId, LastName,FirstName) values ('1', 'Wang', 'Allen');

insert into Address (AddressId, PersonId,City, State) values ('1', '2', 'New York City', 'New York');

 

解法:

select FirstName, LastName, City, State
from Person  P left join Address  Ad on (P.PersonId = Ad.PersonId);

 

posted @ 2019-10-22 20:40  forever_fortunate  阅读(100)  评论(0编辑  收藏  举报