Correlated Subquery Expalnation with Example

Posted by Prabhukiran345 under Sql Server category on | Points: 40 | Views : 422
Correlated Subquery: A query is called correlated subquery when both the inner query and the outer query are interdependent. For every row processed by the inner query, the outer query is processed as well. The inner query depends on the outer query before it can be processed.

SELECT p.product_name FROM product p 
WHERE p.product_id = (SELECT o.product_id FROM order_items o
WHERE o.product_id = p.product_id);

Comments or Responses

Login to post response