http://en.wikipedia.org/wiki/Correlated_subquery
Scenario: Write a query to select all employees from eastern region. DB diagram follows:
--select all employees from Eastern region
select * from employees where EmployeeID in
(
-- select all Employees under territory which comes under Eastern region
select EmployeeID from employeeterritories where TerritoryID in
(
--select all territory for Easter region (RegionID = 1)
select TerritoryID from territories where RegionID = 1
)
)
No comments:
Post a Comment