gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 13:29:02 26 4
gpt4 key购买 nike

第一个查询:

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com