What is the difference?

  • Hi Friends,

    I have a doubt regarding joining two tables, so i came here to get your suggestions...

    What is the differece between the below two queries ? What difference we can see in the result ?

    Could you guys give me valuable suggestions,please?

    select * from table1 join table2 on table1.column = table2.column and table2.column > 100

    select * from table1 join table2 on table1.column = table2.column where table2.column > 100

    Thanks,
    Charmer

  • This was removed by the editor as SPAM

  • As written, they'll do the same thing. Check the execution plans, you'll see what they're doing.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Charmer (9/26/2012)


    Hi Friends,

    I have a doubt regarding joining two tables, so i came here to get your suggestions...

    What is the differece between the below two queries ? What difference we can see in the result ?

    Could you guys give me valuable suggestions,please?

    select * from table1 join table2 on table1.column = table2.column and table2.column > 100

    select * from table1 join table2 on table1.column = table2.column where table2.column > 100

    Thank you Stewart , That make sense to me...If you don't mind, Could you gimme an example queries ..?

    Thanks,
    Charmer

  • Charmer (9/26/2012)


    Charmer (9/26/2012)


    Hi Friends,

    I have a doubt regarding joining two tables, so i came here to get your suggestions...

    What is the differece between the below two queries ? What difference we can see in the result ?

    Could you guys give me valuable suggestions,please?

    select * from table1 join table2 on table1.column = table2.column and table2.column > 100

    select * from table1 join table2 on table1.column = table2.column where table2.column > 100

    Thank you Stewart , That make sense to me...If you don't mind, Could you gimme an example queries ..?

    select * from table1 left join table2 on table1.column = table2.column and table2.column > 100

    select * from table1 left join table2 on table1.column = table2.column where table2.column > 100

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

  • This was removed by the editor as SPAM

  • Thank you so much Stewart....This example is going to help me a lot...I made lot of mistakes in my T-SQL statements with this join with AND , join with WHERE...

    I gotta change everything....You really helped me ....:-)

    Thanks,
    Charmer

Viewing 7 posts - 1 through 6 (of 6 total)

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