下面是两个不同的SQL代码之间有任何性能差异吗?第一个是left jon
,与where
匹配,另一个是left join
,与on
匹配。有/无“左连接”和在“哪里”或“上”匹配的区别?
因为我从那些sql中得到完全相同的结果/输出,但我很快就会使用更大的表(比如几十亿行),所以我不想遇到任何性能问题。在此先感谢...
select a.customer_id
from table a, table b
where a.customer_id = b.customer_id
select a.customer_id
from table a
left join table b
on a.customer_id = b.customer_id
问题是:你想要一个左连接还是一个内连接? – jarlh
2个sql片段做不同的事情 –
[坏习惯踢:使用旧式联接](http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/08/bad-habits-to-kick-使用老的风格,joins.aspx)。 1992年,“内连接”被添加到标准SQL中。这意味着逗号式连接已经过时了*世纪的四分之一*。 –