Neeraj Jain
Neeraj Jain

Reputation: 7730

Better Approach of writing Inner Join?

Which approach should I use ?

This

Select * from table1,table2 where table1.id=table2.id;

or

Select * from table1 inner join table2 on table1.id=table2.id;

Note : Id is foriegn Key .

Upvotes: 0

Views: 64

Answers (2)

Pythonn00b
Pythonn00b

Reputation: 325

If your query gets big as they do, the second style is usually regarded as easier to read and comprehend as the JOIN and the WHERE parts of the query are separated.

Select * from table1 
INNER JOIN table2 on table1.id=table2.id
INNER JOIN table3 on table1.id=table3.id
WHERE table2.something = 1

Indeed both styles should have the same execution pan under the hood.

Upvotes: 0

Smog
Smog

Reputation: 604

In most modern RMDBS both would yield the same execution plan but the second one is the reccommended form since it makes clear what are the join conditions right after you declare said join

Upvotes: 7

Related Questions