June 23, 2013 at 12:45 am
Hi all, I did my home work but just want to confirm where is that Left table on Left SQL :
a. Very Firs mentioned in Select
b. on the Left side of equation in ON statement.
Is this the same:
Select T1.C1, T2.C2
From T1 Left join T2
on T1.C1 =. T2.C2
vs.
Select T1.C1, T2.C2
From T1 Left join T2
on T2.C2 = T1.C1. ------ note t2 first here
What if I do lef5 join on tables which are not on main select? In this case order could be determined from "=" line ?
Tx
Mario
June 23, 2013 at 2:06 am
well, consider it as if you were to write the from part in a (long) single line
In English, we read it from left to right, correct ?
Hence a left outer join will keep all objects mentioned "previously" in the from line.
It doesn't take the on-clause in account to determine what is left/right
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
June 23, 2013 at 12:08 pm
ALZDBA
Hi, Alzdba
Bit hard to get your answer so it's left from the JOIN or left from "="
Mario
June 23, 2013 at 3:19 pm
mario17 (6/23/2013)
ALZDBAHi, Alzdba
Bit hard to get your answer so it's left from the JOIN or left from "="
Mario
It would be to the "left" (before) of the word "JOIN". It makes no difference what order they are in around the "=" sign so do what you will there for the easiest understanding.
--Jeff Moden
Change is inevitable... Change for the better is not.
June 24, 2013 at 12:23 am
unlike the old syntax ( not using the keyword JOIN ) the placement of the on-clause predicates don't play a role in determining the left part of your left join.
left join right
from table1 left join table2 would consider table1 as the left part.
from tableB left join tableA would consider tableB as the left part.
from table1 right join table2 would consider table2 as the right part.
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
July 12, 2013 at 12:23 pm
I hope I dont confuse you here :
Select T1.C1, T2.C2
From T1 Left join T2
on T1.C1 =. T2.C2
is equivalent to
Select T1.C1, T2.C2
From T2 Right join T1
on T1.C1 =. T2.C2
The understanding, important to keep in mind, is that you want all data from table t1 regardless of if it has a join to t2. The same is not true of t2, you only return those that have a join to t1.
----------------------------------------------------
July 13, 2013 at 1:15 am
It's the table left of the JOIN operator for a left join and right of the JOIN operator in a right join.
SELECT *
FROM Table1 -- <-- Left Table (data is preserved in this table)
LEFT JOIN Table2
ON Table1.column = Table2.column
Where.....
SELECT *
FROM Table1
RIGHT JOIN Table2 -- <-- Right Table (data is preserved in this table)
ON Table1.column = Table2.column
Where.....
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply