i




 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What is a Sub-Query?
02-08-2013, 05:32 AM
Post: #1
What is a Sub-Query?
Consider a scenario in which we want to get the Employees that don't belong to some specific department, say 'Admin' having DeptID = 1, we will use inner query like this:

Code:
SELECT *
FROM Employees
WHERE EmployeeID NOT IN (
      SELECT EmployeeID FROM Employee_Dept WHERE DeptID = 1
)

This way only Employees who's IDs are not associated with Admin Dept ID are returned.





View Asad Ali's profile on LinkedIn

Quote




User(s) browsing this thread: 1 Guest(s)