tsql - INNER JOIN和WHERE之间的区别?

标签 tsql inner-join where

第一个查询:

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

第二个查询:
Select * from table1, table2 where table1.Id = table2.Id

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

最佳答案

您发布的两个语句在逻辑上是相同的。真的没有
实际原因是要优先选择一个,这主要是因为
个人风格和可读性。有些人喜欢INNER JOIN语法,
有些人只喜欢使用WHERE

引用Using Inner Joins:

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.



引用Join Fundamentals:

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。我发现它更加清晰,因为我可以将联接条件与过滤条件分开,并为每个联接表使用单独的联接块。

关于tsql - INNER JOIN和WHERE之间的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6248640/

相关文章:

sql - SQL Server 如何判断输入日期的格式?

tsql - 如何在新列中显示汇总数据?

mysql - 如何在cakephp中编写内连接查询

arrays - 在 Where-Object 中排除数组中的项目

c# - LINQ where子句疑惑

sql - 如何从唯一性由 2 列定义的 SQL 中获取唯一的一组行?

SQL - 查找唯一的最小值和关联的列

具有 2 个表的 MySQL 内部连接查询

sql - 将一个表中的值更新到另一个表中

c# - 使用 LINQ 选择本周