MVSFORUMS.com A Community of and for MVS Professionals
SRI123 Beginner Joined: 01 Jun 2012 Posts: 1 Topics: 1
Posted: Fri Jul 27, 2012 3:11 am Post subject: Query for left outer join
Three tables A , B, C with A-> C is one to many and B-> C is one to many.
While writing query for left outer join, can we keep all the 'one to' tables on the left side of the join and 'many' table on the right side?
I need to write a query by using left outer join to fetch the data from these tables with data in the C table is matching with A & B
,B LEFT OUTER JOIN C
ON A.COL1 = C.COL1
AND B.COL1 = C.COL1
is this correct?
kolusu Site Admin Joined: 26 Nov 2002 Posts: 11186 Topics: 70 Location: San Jose
Posted: Fri Jul 27, 2012 11:55 am Post subject:
Combine both tableA and TableB with an INNER JOIN and then perform the OUTER JOIN on tabeC
FROM tablea A INNER JOIN tableb B
ON A.COL1 = B.COL1
LEFT OUTER JOIN tablec C
ON B.COL1 = C.COL1
All times are GMT - 5 Hours
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum