SQL Server:CROSS JOIN和FULL OUTER JOIN有什么区别? [英] SQL Server: What is the difference between CROSS JOIN and FULL OUTER JOIN?

查看:575
本文介绍了SQL Server:CROSS JOIN和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 joinleft outerright 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆