Thursday, 26 January 2017

Difference between inner join and where in select join SQL statement





I have two select join SQL statements:



select a.id from table_a as a, table_b as b where a.id=b.id;
select a.id from table_a as a inner join table_b as b on a.id=b.id;



Obviously, they are the same in result. But is there any difference between them , such as performance, portability.


Answer



One difference is that the first option hides the intent by expressing the join condition in the where clause.



The second option, where the join condition is written out is more clear for the user reading the query. It shows the exact intent of the query.



As far as performance or any other difference, there shouldn't be any. Both queries should return the exact same result and perform the same under most RDBMS.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...