JOIN 与多个 FROM 表 [英] JOIN vs Multiple FROM Tables

查看:22
本文介绍了JOIN 与多个 FROM 表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有过连接不会返回具有相同条件的多个表返回的数据的情况?

Is there ever a case where a join will not return data that a FROM multiple tables with the same conditions returns?

例如

SELECT *
FROM TableNames as Names
INNER JOIN TableNumbers as Numbers on Names.ID = Numbers.ID

VS

SELECT *
FROM TableNames as Names, TableNumbers as Numbers
WHERE Names.ID = Numbers.ID

推荐答案

INNER JOIN(如您的第一个示例中所示)将始终返回与使用相同连接条件的 WHERE 过滤器的笛卡尔连接相同的数据(您的第二个例子).

An INNER JOIN (as in your first example) will always return the same data as your a cartesian join with a WHERE filter that uses the same join criteria (your second example).

但是,请注意,对于 OUTER JOIN,情况并非如此,其中 NULL 值在笛卡尔连接中被过滤掉,并使用 WHERE 过滤器作为连接条件.

However, note that this is not true for OUTER JOINs, where NULL values are filtered out in a cartesian join with a WHERE filter as join criteria.

这篇关于JOIN 与多个 FROM 表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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