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

difference between subquery and correlated subquery


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
Reply with quote

Refer this posts:

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

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

 


Similar Topics
Topic Forum Replies
No new posts Timestamp difference and its average ... DB2 11
No new posts Difference when accessing dataset in ... JCL & VSAM 7
No new posts What is the difference between Taskty... Compuware & Other Tools 2
No new posts Difference between VALIDPROC and CHEC... DB2 3
No new posts Difference between CEE3250C and CEE3204S COBOL Programming 2
Search our Forums:

Back to Top