INNER JOIN关键字|有和没有使用它们 [英] INNER JOIN keywords | with and without using them

查看:93
本文介绍了INNER JOIN关键字|有和没有使用它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SELECT * FROM TableA
INNER JOIN TableB
ON TableA.name = TableB.name

SELECT * FROM TableA, TableB
where TableA.name = TableB.name

哪种是首选方式,为什么? 使用诸如JOIN之类的关键字时,性能会有所不同吗?

Which is the preferred way and why? Will there be any performance difference when keywords like JOIN is used?

谢谢

推荐答案

第二种方法是从join关键字存在之前开始的经典方法.

The second way is the classical way of doing it, from before the join keyword existed.

通常,查询处理器会从两个查询生成相同的数据库操作,因此性能不会有差异.

Normally the query processor generates the same database operations from the two queries, so there would be no difference in performance.

使用join可以更好地描述您在查询中正在做的事情.如果您有很多联接,那也更好,因为联接的表和它的条件是彼此相邻的,而不是将所有表放在一个地方,将所有条件放在另一个地方.

Using join better describes what you are doing in the query. If you have many joins, it's also better because the joined table and it's condition are beside each other, instead of putting all tables in one place and all conditions in another.

另一方面是,使用第二种方法错误地进行无界联接会更容易,从而导致包含两个表中所有组合的交叉联接.

Another aspect is that it's easier to do an unbounded join by mistake using the second way, resulting in a cross join containing all combinations from the two tables.

这篇关于INNER JOIN关键字|有和没有使用它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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