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
 

 

retrieving multiple rows after joining

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Satyajit

New User


Joined: 25 Jan 2006
Posts: 27

PostPosted: Wed Aug 02, 2006 4:38 pm    Post subject: retrieving multiple rows after joining
Reply with quote

How can I get the detail of multiple rows from employee table?
here im getting it for EMP_NO '100005' only. I want the details for EMP_NO '100003' with this.



---------+---------+---------+---------+---------+---------+---------+--
SELECT A.EMP_NO,A.FIRST_NAME,A.LAST_NAME,A.PROJECT_NO,
B.PROJECT_NO,B.LOCATION,B.MGR_NAME
FROM U110760.EMPLOYEE A,
U110760.PROJECT B
WHERE A.PROJECT_NO = B.PROJECT_NO
AND A.EMP_NO = '100005';
---------+---------+---------+---------+---------+---------+---------+--
EMP_NO FIRST_NAME LAST_NAME PROJECT_NO PROJECT_NO LOCATION
---------+---------+---------+---------+---------+---------+---------+--
100005 RAKESH BISWAS 1002 1002 CTS TCX
DSNE610I NUMBER OF ROWS DISPLAYED IS 1
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
Back to top
View user's profile Send private message

DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Wed Aug 02, 2006 11:33 pm    Post subject: Re: retrieving multiple rows after joining
Reply with quote

Code:

    SELECT A.EMP_NO,A.FIRST_NAME,A.LAST_NAME,A.PROJECT_NO,
           B.PROJECT_NO,B.LOCATION,B.MGR_NAME
      FROM U110760.EMPLOYEE A,
           U110760.PROJECT B
     WHERE A.PROJECT_NO = B.PROJECT_NO
       AND A.EMP_NO IN ('100005', '100003')
    ;


Dave
Back to top
View user's profile Send private message
parikshit123

Active User


Joined: 01 Jul 2005
Posts: 269
Location: India

PostPosted: Fri Aug 11, 2006 12:44 pm    Post subject:
Reply with quote

Hi,

What Dave has suggested is a correct query.

But, I wonder, will it not be a good idea to do restrict first and then join?

May be we can use JOIN keyword to do this?

Just an idea not sure if suits your requirement.
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 Unable to create multiple files using... mbattu COBOL Programming 3 Fri May 05, 2017 5:35 pm
This topic is locked: you cannot edit posts or make replies. SDSF multiple spool datasets extracte... PJAlarcon CLIST & REXX 1 Fri Apr 21, 2017 10:50 pm
No new posts Validating file with multiple header/... mohitsaini DFSORT/ICETOOL 6 Thu Apr 13, 2017 1:53 am
No new posts Data replication from multiple Db2 ta... kishpra DB2 9 Mon Mar 27, 2017 9:58 pm
No new posts Unable to catalog a gdg dataset resid... Shovan JCL & VSAM 7 Fri Mar 24, 2017 2:24 pm


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