Correlated Subquery

Creating Simple Queries, Hierarchical Queries, Sorting Query Results, Joins, Unnesting of Nested Subqueries and Distributed Queries.
Post Reply
Posts: 62
Joined: Fri Nov 23, 2018 2:51 am

Correlated Subquery

Post by dsusmitha » Tue Dec 04, 2018 6:12 am

What is Correlated Subquery?

Posts: 142
Joined: Fri Nov 23, 2018 2:48 am

Re: Correlated Subquery

Post by AyubHussain » Tue Dec 04, 2018 6:13 am

Correlated Query is nothing but the subquery whose output is depending on the inner query used in that query.Correlated query is the query which is executed after the outer query is executed.The outer query is always dependent on inner query.
The approach of the correlated subquery is bit different than normal subqueries.

In normal subqueries the inner queries are executed first and then the outer query is executed but in Correlated Subquery outer query is always dependent on inner query so first outer query is executed then inner query is executed.Correlated Subqueries always uses operator like Exist,Not Exist,IN,Not IN.

“Correlated Queries are also called as Synchronized queries…”

Posts: 85
Joined: Thu Jan 03, 2019 3:58 am

Re: Correlated Subquery

Post by srini » Thu Jan 10, 2019 5:20 am

Correlated subqueries are used for row-by-row processing. Each subquery is executed once for every row of the outer query.
A correlated subquery is evaluated once for each row processed by the parent statement. The parent statement can be a SELECT, UPDATE, or DELETE statement.
A correlated subquery requires the outer query to be executed first, the correlated subquery must run once for every row in the outer query. This causes correlated subqueries to be less efficient than other subqueries.

Post Reply

Return to “SQL Queries and Subqueries”