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
 

 

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
No new posts Difference between TWALENG and TWASIZE Arunkumar Chandrasekaran CICS 3 Tue Jan 03, 2017 12:57 pm
No new posts Sticky: difference between ... DUMMY ... and ... enrico-sorichetti JCL & VSAM 0 Mon Oct 17, 2016 4:31 pm
No new posts Difference space showed for TS and it... autobox DB2 1 Thu Apr 14, 2016 1:07 pm
No new posts Difference Between CICS WebSupport an... sachinji84 CICS 1 Mon Mar 07, 2016 7:25 pm
No new posts Difference between -180 and -181 with... deepak_shrivastava DB2 4 Wed Jan 06, 2016 10:00 am


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