Difference between INNER JOIN and WHERE?

后端 未结 2 1942
广开言路
广开言路 2020-12-16 05:26

First Query:

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

Second Query:



        
2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-16 05:58

    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.

    Refering to 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.

    Refering to 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.

    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.

提交回复
热议问题