Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
difference between subquery and correlated subquery

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

New User


Joined: 19 Feb 2005
Posts: 13

PostPosted: Fri Mar 25, 2005 10:50 pm    Post subject: difference between subquery and correlated subquery
Reply with quote

Hi all,
i want to know exact difference between subquery and correlated subquery with example[/u].
Back to top
View user's profile Send private message

priya

Moderator


Joined: 24 Jul 2003
Posts: 568
Location: Bangalore

PostPosted: Mon Mar 28, 2005 8:08 am    Post subject:
Reply with quote

Refer this posts:

http://www.ibmmainframes.com/viewtopic.php?t=1736&highlight=correlated+subquery

http://www.ibmmainframes.com/viewtopic.php?p=898
Back to top
View user's profile Send private message
learnmf

Active User


Joined: 14 Mar 2005
Posts: 123

PostPosted: Tue Mar 29, 2005 8:31 pm    Post subject:
Reply with quote

Quote:
i want to know exact difference between subquery and correlated subquery with example

Hi friend
in subqury our execution takes place in top down order where as in corelated subquery it is bottom up manner
Back to top
View user's profile Send private message
Girishm

New User


Joined: 09 Mar 2005
Posts: 35
Location: Mysore

PostPosted: Fri Apr 01, 2005 3:36 pm    Post subject: Re: difference between subquery and correlated subquery
Reply with quote

SUBQUERY:
A query may contain more than one sub query. The inner most query (bottem) will get executed first, next the higher,so on and at last the first query (top) will be execuited. A non-correlated subquery is the one in which each query is independent of eachother.
SELECT EMP_NAME, DEPTNO FROM EMP
WHERE EMP_NAME IN (SELECT EMP_NAME FROM DEPT)

CORRELATED SUBQUERY:
Here for each row of the outer table the inner table will be evaluated and the result if the inner table will be sent one row at a time. That means, there exists corelation between the two tables.
See the below example:
SELECT EMP_NAME, DEPTNO FROM EMP
WHERE EMP_NAME IN (SELECT EMP_NAME FROM DEPT WHERE EMP.DEPTNO = DEPT.DEPTNO)

_____________
GM
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
This topic is locked: you cannot edit posts or make replies. Difference between EQUAL and EQUAL TO... jithinraghavan COBOL Programming 3 Thu Apr 19, 2018 2:22 am
No new posts ISMF Difference between volume count ... upendrasri IBM Tools 2 Tue Dec 05, 2017 12:40 pm
No new posts Finding difference between two PS fil... Vignesh Sid SYNCSORT 5 Mon Oct 30, 2017 1:13 pm
No new posts Difference in SORT & ICETOOL Mohan Kothakota DFSORT/ICETOOL 5 Fri Sep 22, 2017 4:56 pm
No new posts Difference between TWALENG and TWASIZE Arunkumar Chandrasekaran CICS 3 Tue Jan 03, 2017 12:57 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us