SQL Server 中的 LEFT JOIN 与 LEFT OUTER JOIN

LEFT JOIN vs. LEFT OUTER JOIN in SQL Server(SQL Server 中的 LEFT JOIN 与 LEFT OUTER JOIN)
本文介绍了SQL Server 中的 LEFT JOIN 与 LEFT OUTER JOIN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

LEFT JOINLEFT 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
SSIS: Model design issue causing duplications - can two fact tables be connected?(SSIS:模型设计问题导致重复-两个事实表可以连接吗?)
SQL Server Graph Database - shortest path using multiple edge types(SQL Server图形数据库-使用多种边类型的最短路径)
Invalid column name when using EF Core filtered includes(使用EF核心过滤包括时无效的列名)
How should make faster SQL Server filtering procedure with many parameters(如何让多参数的SQL Server过滤程序更快)
How can I generate an entity–relationship (ER) diagram of a database using Microsoft SQL Server Management Studio?(如何使用Microsoft SQL Server Management Studio生成数据库的实体关系(ER)图?)