题意:无论一个人的地址是否存在,都要將他的FirstName, .LastName, City, State输出
思路:一开始以为只是普通的等值连接,发现wa了,错误提示表名正确答案有输出firstname,lastname,null,null,也就是存在这么一些数据,在Person表里有此人的Id,在Adderss表里没有此人的Id,但题目说了不管这个人有没有地址,必须输出FirstName, .LastName, City, State
然后学习了left outer join
学习链接:http://chinaxxren.iteye.com/blog/628232
题目链接:https://leetcode.com/problems/combine-two-tables/
select x.FirstName, x.LastName, y.City, y.State
from Person as x left outer join Address as y
on x.PersonId = y.PersonId /* 这里是on,不是where */ ;