创建表和数据:
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);
leetcode175 组合两个表 Combine Two Tables
原文:https://www.cnblogs.com/forever-fortunate/p/11722386.html