SQL Server Performance Forum – Threads Archive
Join on multiple fields
How can you write a join between multiple fields between tables? Declare cursor on
Select …
From TableA Left Join TableB
On TableA.F1 = TableB.F1
On TableA.F2 = TableB.F2 I get an error if I try to separte this into two different joins and
get an error if I try anything like the above. The only thing I could
think of was the old fashioned where clause Where TableA.F2 = tableB.F2 but
it’s a left join and there may not be a corresponding TableB record. Thank you.
Correct the join as below: Select …
From TableA Left Join TableB
On TableA.F1 = TableB.F1 AND TableA.F2 = TableB.F2
CanadaDBA
Thank you. Worked very well. I am joining all over the place!
]]>