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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Grouping by multiple headers DFSORT/ICETOOL 7
Search our Forums:

Back to Top