C#, SQL Server, WCF, MVC and ASP .NET video tutorials for beginners
In this video we will discuss about Corelated Subqueries
Link for the text version of this video
In Part 59, we discussed about 2 examples that uses subqueries. Please watch Part 59, before proceeding with this video. We will be using the same tables and queries from Part 59.
In the example below, sub query is executed first and only once. The sub query resutls are then used by the outer query. In a non-corelated subquery, the subquery can be executed independently of the outer query.
Select [Id], [Name], [Description]
from tblProducts
where Id not in (Select Distinct ProductId from tblProductSales)
If the subquery depends on the outer query for its values, then that sub query is called as a correlated subquery. In the where clause of the subquery below, “ProductId“ column get it’s value from tblProdu