T SQL Joins

  • Hi,

    I have a simple query regarding joins, please see the examples below.

    The only difference between the examples is that in script a the join is made with b.key and in script b the join is from a.key. What I want to know is that does this make any difference at all??

    Script A

    select * from table_a a

    join table_b b on b.key = a.key

    Script B

    select * from table_a a

    join table_b b on a.key = b.key

  • Nope, it does not.

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • In the future, you can answer questions like this one for yourself by displaying the actual execution plans when you run the two queries. You should see identical joins in this instance.

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • Thanks for your reply, I will bear that in mind.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply