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 subquery

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

New User


Joined: 14 Dec 2005
Posts: 22
Location: India

PostPosted: Wed Jan 18, 2006 2:03 pm    Post subject: Using subquery
Reply with quote

Hi all can we use subquery to retrive multiple rows.
My query is of like this
SELECT * FROM EMP
WHERE EMP_ID = (SELECT EMP_ID FROM TEMPA
WHERE DIR_ID =
( SELECT DIR_ID FROM TDIR
WHERE DIR_CTRY_CD <> 'US'));

For the above query I am getting an sql code of -811.
Can you guyz send me some sample subquery..
Back to top
View user's profile Send private message

radhakrishnan82

Active User


Joined: 31 Mar 2005
Posts: 436
Location: chennai, India

PostPosted: Wed Jan 18, 2006 2:06 pm    Post subject:
Reply with quote

Code:
can we use subquery to retrive multiple rows

Yes.
Use cursor to retrieve mulitple rows.

hope this helps.
Back to top
View user's profile Send private message
sairam

New User


Joined: 30 Aug 2005
Posts: 58
Location: Kolkata

PostPosted: Wed Jan 18, 2006 2:15 pm    Post subject:
Reply with quote

Hi,
try the following IN instead of '='

SELECT * FROM EMP
WHERE EMP_ID IN (SELECT EMP_ID FROM TEMPA
WHERE DIR_ID IN
( SELECT DIR_ID FROM TDIR
WHERE DIR_CTRY_CD <> 'US'));
Back to top
View user's profile Send private message
jwell rymbei

New User


Joined: 14 Dec 2005
Posts: 22
Location: India

PostPosted: Wed Jan 18, 2006 2:31 pm    Post subject: Re: Using subquery
Reply with quote

Hi,
Radhakrishnan.
i need to use the query in SPUFI only..

Sairam..
I tried with IN and it worked..thanks a lot...
you r the man..
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 Subquery inside a Updatable cursor in... easebourne_ironfist DB2 8 Wed Jun 12, 2013 2:02 pm
No new posts Can we have correlated subquery in De... saurabh_24jul COBOL Programming 13 Fri Oct 28, 2011 10:59 pm
No new posts delete duplicate records using a subq... l.nethaji DB2 5 Thu Nov 25, 2010 2:13 pm
This topic is locked: you cannot edit posts or make replies. Difference between Corrrelated Subque... Sudeshna Sarkar DB2 2 Sat May 15, 2010 3:18 pm
No new posts Upadate specific columns using Co-rel... Learncoholic DB2 8 Tue May 11, 2010 12:35 am


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