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 |
|
sqlclarify
Yak Posting Veteran
56 Posts |
Posted - 2009-05-11 : 02:15:46
|
| In www.w3schools.com , the syntax for left joins is given as:SELECT column_name(s)FROM table_name1LEFT JOIN table_name2ON table_name1.column_name=table_name2.column_nameBut I notice some people reverse the join condition.. does that produce the same results?SELECT column_name(s)FROM table_name1LEFT JOIN table_name2ON table_name2.column_name=table_name1.column_name |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-05-11 : 02:24:16
|
quote: Originally posted by sqlclarify In www.w3schools.com , the syntax for left joins is given as:SELECT column_name(s)FROM table_name1LEFT JOIN table_name2ON table_name1.column_name=table_name2.column_nameBut I notice some people reverse the join condition.. does that produce the same results?SELECT column_name(s)FROM table_name1LEFT JOIN table_name2ON table_name2.column_name=table_name1.column_name
YesMadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-05-11 : 11:16:59
|
quote: Originally posted by sqlclarify In www.w3schools.com , the syntax for left joins is given as:SELECT column_name(s)FROM table_name1LEFT JOIN table_name2ON table_name1.column_name=table_name2.column_nameBut I notice some people reverse the join condition.. does that produce the same results?SELECT column_name(s)FROM table_name1LEFT JOIN table_name2ON table_name2.column_name=table_name1.column_name
the order in which columns are compared in on does not affect the results. The only think to be careful are which table you use on left and right side of left join. also it would be better to use short aliases rather than repeating table name everywhere likeSELECT column_name(s)FROM table_name1 t1LEFT JOIN table_name2 t2ON t1.column_name=t2.column_name |
 |
|
|
|
|
|