Raj
Raj

Reputation: 487

SQL query: 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              AllocatedID
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

Upvotes: 1

Views: 303

Answers (1)

Antony
Antony

Reputation: 3781

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

Note this assumes the allocatedid is a deptid

Upvotes: 1

Related Questions