INNER JOIN和WHERE之间的区别? [英] Difference between INNER JOIN and WHERE?

查看:614
本文介绍了INNER JOIN和WHERE之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首次查询:

Select * from table1 inner join table2 on table1.Id = table2.Id

第二个查询:

Select * from table1, table2 where table1.Id = table2.Id

这些关于性能的查询之间应该有什么区别?

What is difference between these query regarding performance which should one use?

推荐答案

您发布的两个语句在逻辑上是相同的.真的没有 实际原因是要优先选择另一个,这在很大程度上取决于 个人风格和可读性.有些人喜欢 INNER JOIN 语法和 有些人只喜欢使用位置.

The two statements you posted are logically identical. There isn't really a practical reason to prefer one over the other, it's largely a matter of personal style and readability. Some people prefer the INNER JOIN syntax and some prefer just to use WHERE.

引用使用内部联接:

在ISO标准中,内部联接可以 在FROM或 WHERE子句.这是唯一的类型 加入ISO支持的WHERE 条款.在指定的内部联接 WHERE子句被称为旧样式 内部联接.

In the ISO standard, inner joins can be specified in either the FROM or WHERE clause. This is the only type of join that ISO supports in the WHERE clause. Inner joins specified in the WHERE clause are known as old-style inner joins.

引用加入基础知识:

在 FROM子句有助于将它们与 任何可能的其他搜索条件 在WHERE子句中指定,并且是 推荐的指定方法 加入.

Specifying the join conditions in the FROM clause helps separate them from any other search conditions that may be specified in a WHERE clause, and is the recommended method for specifying joins.

我个人更喜欢使用INNER JOIN.我发现它更清晰了,因为我可以将联接条件与过滤条件分开,并为每个联接表使用单独的联接块.

Personaly, I prefer using INNER JOIN. I find it much clearer, as I can separate the join conditions from the filter conditions and using a seperate join block for each joined table.

这篇关于INNER JOIN和WHERE之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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