what is the difference between the query and corelated
query
Answers were Sorted based on User's Feedback
Answer / guru
Correlated Query: If a sub query has a Reference with the
value or values of Main Query , It is called as Correlated
Sub query.
Thanks
Is This Answer Correct ? | 11 Yes | 2 No |
Answer / saurabh
When 1st main query is executed then the result of the main
query is used in teh where clause of subquery then this
type of subquery is called as co-related sub query.
Is This Answer Correct ? | 7 Yes | 0 No |
Answer / aravinda
query: query is single time validation of conditions for
entire result once result is fetched there no further
validation of records.
corelated sub query : each record is validated with inner
query aftr fetch.
1) outer query will execute first and pass a value to inner
query.
2) based on outer query value inner query will execute.
3) based on inner query value the outer query record will be
validated.
inner query will execute for every record of outer query( if
outer query has 10 records inner query will execute 10 times)
Is This Answer Correct ? | 6 Yes | 0 No |
Answer / manish
select * from emp; --->> query
select * from emp where sal=(select max(sal) from emp);
--> here a sub query is also there
select * from emp outer where sal= ( select avg(sal) from
emp e where dept.e=dept.outer) --> corelated query
Is This Answer Correct ? | 9 Yes | 7 No |
Answer / chintu
A query is nothing but if we want to evaluate one thing we
will write query. like
select * from emp; --->> query
A Query is evaluated once for each and every row from the
parent statement is called corellated Query.
like
select * from emp outer where sal= ( select avg(sal) from
emp e where dept.e=dept.outer) --> corelated query
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / lova raju allumalla
when performing joins on two or more tables, we normally
write a query making use relational operators such as =
etc. which means each and every row of every table is
compared with each other,which is a unwanted situation when
looked in the perspective performance issue. where as
making use of corelated query one can minimise the tedoius
checks as described above. consider the example below with
a normal join
select * from emp e,dept d where e.deptno=d.deptno;
now the above same can be performed by using the co related
query
select * from emp where deptno in (select deptno from dept);
u can now make up the difference, in the first approach in
emp table, each row deptno value compared for each row
deptno value of dept table.where as in second approach the
(select deptno from dept) is executed only once for all
checks of the outer query select * from emp where deptno
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / amar_kondla
select * from emp----- is a query;
and
co-related query is sub one of sub qury( sub qury
means--whose returning values are filtering the condition
of the main query)
ex; SELECT * FROM EMP E
WHERE E.SAL>( SELECT AVG(SAL) FROM EMP F
WHERE E.DEPTNO= F.DEPTNO);
SO HERE WE R FINDING THE EMPLOYEE WHO HAS GETTING MORE THAN
AVG(SAL) OF RESPECTING DEPTNO.
AND CO RELATED SUB QUERY ALWAYS USE ALIAS NAME FOR TABLE, IT
SIMILAR LIKE JAIN(SELF JOIN)
Is This Answer Correct ? | 3 Yes | 4 No |
Answer / guruswamy
corelated query is refered by each an every value by
subquery.
normal query is referd by subquery one bulk amount to get a
main query
Is This Answer Correct ? | 2 Yes | 3 No |
What is the purpose of my sql?
Why do we need databases?
SELECT ROUND(TRUNC(MOD(1600,10),-1),2) FROM dual;
What is a crud api?
Is join same as left join?
How does an execution block start and end in pl sql?
What are different types of queries in sql?
When can we use the where clause and the having clause?
What is the difference between cross join and natural join?
Which is better stored procedure or query?
What is the difference between local and global temporary table?
What is meant by Materialized view?
2 Answers iGate, Marlabs, Polaris,