Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

using OUTER JOIN in SQL query

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: using OUTER JOIN in SQL query
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    Post subject:
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    Post subject: Re: using OUTER JOIN in SQL query
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    Post subject:
Reply with quote

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

Check below link: icon_idea.gif
http://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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am
No new posts Join of more than one table dibyendumandal11111 DB2 6 Mon Feb 13, 2017 11:36 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us