IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

using OUTER JOIN in SQL query


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Vinay Kumar N.J

New User


Joined: 24 Sep 2009
Posts: 1
Location: Bangalore

PostPosted: Thu Sep 24, 2009 7:16 pm
Reply with quote

How to use LEFT OUTER JOIN and RIGHT OUTER JOIN in an SQL Query?
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Sep 24, 2009 7:53 pm
Reply with quote

Use Manuals on top of this page
Back to top
View user's profile Send private message
lkhiger

New User


Joined: 28 Oct 2005
Posts: 89

PostPosted: Fri Sep 25, 2009 9:11 am
Reply with quote

Vinay Kumar N.J wrote:
How to use LEFT OUTER JOIN and RIGHT OUTER JOIN in an SQL Query?


You can use LEFT JOIN instead of LEFT OUTER JOIN and never use
RIGHT OUTER JOIN because DB2 replace all RIGHT OUTER JOINs by
LEFT JOINs, which is cost CPU time.

Lenny icon_smile.gif
Back to top
View user's profile Send private message
bhairon singh rathore

New User


Joined: 19 Jun 2008
Posts: 91
Location: banglore

PostPosted: Fri Sep 25, 2009 12:21 pm
Reply with quote

Google and you will find million examples for left outer join.

Check below link: icon_idea.gif
publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db29.doc.apsg/db2z_joinleftouter.htm
Back to top
View user's profile Send private message
ajeshrn

New User


Joined: 25 Mar 2009
Posts: 78
Location: India

PostPosted: Tue Oct 20, 2009 2:15 pm
Reply with quote

Hi Vinay,

Please find a sample left outer query below:

Format 1:

select a.emp_name
,b.emp_desg_des
from
(Select emp_name, emp_desg_cd
from employee)a
LEFT OUTER JOIN
(Select emp_desg_cd,emp_desg_des
from Designation)b
ON a.emp_desg_cd = b.emp_desg_cd

Format 2:

select a.emp_name
,b.emp_desg_des
from employee a
left join Designation b
ON a.emp_desg_cd = b.emp_desg_cd


lkhiger,

Thanks for the information, I never new that DB2 will replace all RIGHT OUTER JOINs by LEFT JOINs, which is cost CPU time.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Oct 20, 2009 3:07 pm
Reply with quote

Quote:
Thanks for the information, I never new that DB2 will replace all RIGHT OUTER JOINs by LEFT JOINs, which is cost CPU time.


that comes as no suprise. you obviously have not read any manuals.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Join multiple records using splice DFSORT/ICETOOL 5
Search our Forums:

Back to Top