Correlated Subquery
In Correlated Query, Outer query executes first and for every Outer query row Inner query is executed. Hence, the Inner query uses values from the Outer query.
Example:
Orders (OrderID , OrderDate);
Customers (CustomerID, CustomerName, ContactName, Country);
Find details of customers who have ordered.
Query
SELECT * FROM Customers where
EXISTS (SELECT CustomerID FROM Orders
WHERE Orders.OrderID=Customers.CustomerID);
Output
Difference between Nested Subquery, Correlated Subquery and Join Operation
Joins are used to combine two or more different tables based on a common field between them with the help of this we can easily retrieve the data from multiple tables. So, In this article, we are going to discuss the JOIN Operation, and Subquery in detail. Let’s start with the JOIN operation.
Contact Us