View previous topic :: View next topic
|
Author |
Message |
surya
New User
Joined: 19 Feb 2005 Posts: 13
|
|
|
|
Hi all,
i want to know exact difference between subquery and correlated subquery with example[/u]. |
|
Back to top |
|
|
priya
Moderator
Joined: 24 Jul 2003 Posts: 568 Location: Bangalore
|
|
Back to top |
|
|
learnmf
Active User
Joined: 14 Mar 2005 Posts: 123
|
|
|
|
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 |
|
|
Girishm
New User
Joined: 09 Mar 2005 Posts: 35 Location: Mysore
|
|
|
|
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 |
|
|
|