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.
| Author |
Topic |
|
soorajtnpki
Posting Yak Master
231 Posts |
Posted - 2008-10-23 : 03:33:12
|
| Hi all,can u solve my doubt regarding join What is the difference between the two queries belowselect * from table1 inner join table2 on table1.id=table2.id AND table1.status=1select * from table1 inner join table2 on table1.id=table2.id WHERE table1.status=1Shall above two queries give the same result every time.?thanks in advance.... |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-23 : 03:40:29
|
| because its inner join i dont think it really matters if condition is given on WHERE or ON clause.however, in case of outer joins they yield different results. |
 |
|
|
soorajtnpki
Posting Yak Master
231 Posts |
Posted - 2008-10-23 : 04:37:09
|
| ok, if i am using left join, will the above query gives different results..as belowselect * from table1 inner join table2 on table1.id=table2.id AND table1.status=1select * from table1 left join table2 on table1.id=table2.id WHERE table1.status=1if the query gives different results , what was the reason for tat...ok tanx |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-23 : 04:41:01
|
| see thishttp://weblogs.sqlteam.com/jeffs/archive/2007/05/14/60205.aspx |
 |
|
|
soorajtnpki
Posting Yak Master
231 Posts |
Posted - 2008-10-23 : 05:28:45
|
| ok tanx |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-23 : 05:32:03
|
welcome |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2008-10-23 : 07:18:50
|
quote: Originally posted by visakh16 because its inner join i dont think it really matters if condition is given on WHERE or ON clause.....
It doesn't, you get the same query plan either way.-------------Charlie |
 |
|
|
|
|
|