问题描述
LEFT JOIN
和 LEFT OUTER JOIN
有什么区别?
推荐答案
根据文档:FROM (Transact-SQL):
<join_type> ::=
[ { INNER | { { LEFT | RIGHT | FULL } [ OUTER ] } } [ <join_hint> ] ]
JOIN
关键字OUTER
被标记为可选(括在方括号中).在这种特定情况下,是否指定 OUTER
没有区别.请注意,虽然 join 子句的其他元素也被标记为可选,但将 它们 排除在外 将 有所作为.
The keyword OUTER
is marked as optional (enclosed in square brackets). In this specific case, whether you specify OUTER
or not makes no difference. Note that while the other elements of the join clause is also marked as optional, leaving them out will make a difference.
例如,JOIN
子句的整个类型部分是可选的,在这种情况下,如果您只指定 JOIN
,则默认为 INNER
>.换句话说,这是合法的:
For instance, the entire type-part of the JOIN
clause is optional, in which case the default is INNER
if you just specify JOIN
. In other words, this is legal:
SELECT *
FROM A JOIN B ON A.X = B.Y
以下是等效语法的列表:
Here's a list of equivalent syntaxes:
A LEFT JOIN B A LEFT OUTER JOIN B
A RIGHT JOIN B A RIGHT OUTER JOIN B
A FULL JOIN B A FULL OUTER JOIN B
A INNER JOIN B A JOIN B
还要看看我在另一个 SO 问题上留下的答案:SQL 左连接与 FROM 行上的多个表?一>.
Also take a look at the answer I left on this other SO question: SQL left join vs multiple tables on FROM line?.
这篇关于SQL Server 中的 LEFT JOIN 与 LEFT OUTER JOIN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!