开发者

SQL query: How can I get the corresponding employee id which are not allotted to department?

开发者 https://www.devze.com 2023-02-16 10:07 出处:网络
I have Employee and Department table. How can I get the corresponding employee id which are not allotted to department?

I have Employee and Department table. How can I get the corresponding employee id which are not allotted to department?

Employee Table      department table    AllocatedDetails
EmpID               DeptID              All开发者_如何转开发ocatedID
Name                Name                EmpID

Now I have to retrieve the EmpID which is not in the table AllocatedDetails.

Can anyone help me please.....

Note: I need SQL query only


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

Note this assumes the allocatedid is a deptid

0

精彩评论

暂无评论...
验证码 换一张
取 消