sql问题请高手解答一下
有两张表
Employee
EmployID EmployName DepartmentID
001 A 001
002 B 002
003 C 003
Department
DepartmentID DepartmentName Address
001 D1 Shanghai
002 D2 Shanghai
003 D3 Beijing
比较以下两条sql语句有什么不同,为什么?
select e.employName,d.departmentName from Employee e left join Department d on e.DepartmentID=d.DepartmentID where address= 'Shanghai '
select e.employName,d.departmentName from Employee e left join Department d on e.DepartmentID=d.DepartmentID and d.Address= 'Shanghai '
------解决方案--------------------连接后筛选
筛选后连接
------解决方案--------------------第一个先链接再筛选,是从新的表里选出数据
第二个是表连接的时候进行双条件左联,所以数据是主表的全部,属表的条件筛选