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

retrieving multiple rows after joining


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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
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 All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Joining files with intermittent heade... SYNCSORT 1
No new posts Format data from multiple records usi... SYNCSORT 4
No new posts To Sort detail records in a file with... SYNCSORT 5
No new posts To Populate Trailer cnt in the file w... SYNCSORT 1
No new posts Multiple INSPECTS on a big size file COBOL Programming 6
Search our Forums:


Back to Top