SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 inner join
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kt
Yak Posting Veteran

82 Posts

Posted - 05/01/2013 :  10:10:28  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

3715 Posts

Posted - 05/01/2013 :  10:42:59  Show Profile  Reply with Quote
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

India
52325 Posts

Posted - 05/02/2013 :  01:14:02  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000