简体   繁体   中英

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 .

在大多数现代RMDBS中,两者都会产生相同的执行计划,但是第二种是推荐的形式,因为它可以在您声明所说的join之后立即弄清楚join条件是什么

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM