【发布时间】:2016-05-10 19:45:45
【问题描述】:
我是 SQL 新手。我遇到的问题是,当我使用 LEFT JOIN 时,我试图从逻辑上理解对 From 子句的限制,我已经学习了对 where 子句的限制,但我以前从未见过这个。我看了这篇文章,https://stackoverflow.com/questions/8311096/whats-the-difference-between-where-clause-and-on-clause-when-table-left-join#= 但我还是一头雾水。
所以我的代码是这样的。
Select e.last_name
,e.first_name
,e.marital_status_code
,ms.short_desc
from entity e
left join marital_status ms
on e.marital_status_code = ms.marital_status_code AND ms.marital_status_code = 'M'
where e.last_name = 'Hello'
order by 3
;
当我对 Where 子句进行限制时,我完全明白了
喜欢
where e.last_name = 'Hello'
AND marital_status_code = 'M'
order by 3
;
当我像这样对 From 子句施加限制时,请帮助我发生了什么/逻辑是如何工作的
left join marital_status ms
on e.marital_status_code = ms.marital_status_code AND ms.marital_status_code = 'M'
【问题讨论】:
标签: sql outer-join