SubQuery :
In sub query the inner query is executed only once. Depeding upon the results of inner query outer query is evaluated.
Ex:
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);
Correlated SubQuery :
In correlated subquery the inner query is evaluated once for each row processed by the parent statement or outer query.
Ex:
SELECT id, first_name FROM student_details
WHERE first_name IN (SELECT first_name FROM student_details WHERE subject= 'Science');
Tuesday, September 14, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment