SQL Server:CROSS JOIN和FULL OUTER JOIN有什么区别? [英] SQL Server: What is the difference between CROSS JOIN and FULL OUTER JOIN?
问题描述
SQL Server中的CROSS JOIN和FULL OUTER JOIN有什么区别?
What is the difference between CROSS JOIN and FULL OUTER JOIN in SQL Server?
它们是否相同?请解释.什么时候会使用其中任何一个?
Are they the same, or not? Please explain. When would one use either of these?
推荐答案
交叉连接在两个表之间产生笛卡尔积,并返回所有行的所有可能组合.它没有on
子句,因为您只是将所有内容连接到所有内容.
A cross join produces a cartesian product between the two tables, returning all possible combinations of all rows. It has no on
clause because you're just joining everything to everything.
A full outer join
是left outer
和right outer
连接的组合.它返回两个表中与查询的where
子句匹配的所有行,并且在无法满足这些行的on
条件的情况下,它将在未填充的字段中放入null
值.
A full outer join
is a combination of a left outer
and right outer
join. It returns all rows in both tables that match the query's where
clause, and in cases where the on
condition can't be satisfied for those rows it puts null
values in for the unpopulated fields.
这篇维基百科文章介绍了各种类型的联接,并给出了输出示例.样本表集.
This wikipedia article explains the various types of joins with examples of output given a sample set of tables.
这篇关于SQL Server:CROSS JOIN和FULL OUTER JOIN有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!