Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 inner join

Author  Topic 

kt
Yak Posting Veteran

88 Posts

Posted - 2013-05-01 : 10:10:28
I am query inner join with mutiple tables and only want to query out the code BCF from b table. Both queries below give me the same results, but i am not sure which one is the the correct and help with
performace issue.

Query # 1
select a.date_delivery, a.desc, b.puNo, c.item
from sale_order a
inner join purchase b
on a.saleNo = b.saleNo
inner join itemMs c
on c.item = b.item
where b.CodeNo = 'BCF'


Query # 2
select a.date_delivery, a.desc, b.puNo, c.item
from sale_order a
inner join purchase b
on a.saleNo = b.saleNo and b.CodeNo = 'BCF'
inner join itemMs c
on c.item = b.item


thank you,

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-05-01 : 10:42:59
Shouldn't make a difference - both are correct and you can use either, given that you are using INNER JOINS. Both should generate the same query plans as well.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-02 : 01:14:02
the difference will only come into play for OUTER JOINS

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -