SQL查询:如何获取未分配给部门的相应员工ID?

时间:2011-03-10 05:31:19

标签: sql-server-2005

我有EmployeeDepartment表。如何获得未分配给部门的相应员工ID?

Employee Table      department table    AllocatedDetails
EmpID               DeptID              AllocatedID
Name                Name                EmpID

现在我必须检索表EmpID中没有的AllocatedDetails

任何人都可以帮助我.....

注意:我只需要SQL查询

1 个答案:

答案 0 :(得分:1)

select empid, name
from employee
where empid not in (select empid from allocatedDetails)

请注意,这假设assignedid是deptid