Author |
Topic |
Gekko
Yak Posting Veteran
63 Posts |
Posted - 2012-01-31 : 12:48:26
|
hallowhen I write query left outer join or (right outer join) how I know which table is the left or right ?how to differentiate left table, right table?thanks |
|
skybvi
Posting Yak Master
193 Posts |
Posted - 2012-01-31 : 12:51:53
|
its in the order of your writngfor ex ..select * from A left JOIN B on A. =B. Here A is left tableB is right table.Regards,SushantDBAVirgin Islands(U.K) |
 |
|
X002548
Not Just a Number
15586 Posts |
|
Gekko
Yak Posting Veteran
63 Posts |
Posted - 2012-01-31 : 13:15:26
|
quote: Originally posted by skybvi its in the order of your writngfor ex ..select * from A left JOIN B on A. =B. Here A is left tableB is right table.
I understand when I writex x x left outer joinon TabA=TabBit means TabA is left and TabB is right |
 |
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2012-01-31 : 13:16:58
|
quote: Originally posted by Gekko hallowhen I write query left outer join or (right outer join) how I know which table is the left or right ?how to differentiate left table, right table?thanks
Sql reads from left to right. So, the table preceeding a join is always the LEFT and the table following the join is the RIGHT. But, since you are asking about LEFT and RIGHT joins, are you asking which table is the Dominant and Subordinate? |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-01-31 : 13:17:19
|
quote: Originally posted by Gekko hallowhen I write query left outer join or (right outer join) how I know which table is the left or right ?how to differentiate left table, right table?thanks
the side determines side in which tables come in query with respect to join. so tables on left side of join are left tables and on right are right tables------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-01-31 : 13:26:30
|
quote: Originally posted by Gekko
quote: Originally posted by skybvi its in the order of your writngfor ex ..select * from A left JOIN B on A. =B. Here A is left tableB is right table.
I understand when I writex x x left outer joinon TabA=TabBit means TabA is left and TabB is right
not exactlyits like xxx xleft outer join yyy yon y.somecolumn=x.somecolumnhere xxx is left table,yyy is right tablex and y are short names (aliases) for the tables for easy reference------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
jeffw8713
Aged Yak Warrior
819 Posts |
Posted - 2012-01-31 : 14:31:01
|
quote: I understand when I writex x x left outer joinon TabA=TabBit means TabA is left and TabB is right
The order of the predicates in the join do not determine this.SELECT ... FROM tableA a LEFT JOIN tableB b ON a.key = b.keySELECT ... FROM tableA a LEFT JOIN tableB b ON b.key = a.keyBoth of the above are the same...SELECT ... FROM tableA a LEFT JOIN tableB b ON a.key = b.keySELECT ... FROM tableB b LEFT JOIN tableA a ON b.key = a.keyBoth of the above are not the same - regardless of the order of the predicates in the ON clause.Jeff |
 |
|
Gekko
Yak Posting Veteran
63 Posts |
Posted - 2012-01-31 : 14:43:08
|
thanks for definition, constructions |
 |
|
|