如何在不使用嵌套查询的情况下找到没有员工的部门?

时间:2014-10-18 14:01:37

标签: mysql

我有两张桌子:

employee(e_id,e_name,d_id),department(d_id,d_name)

我的查询是:

select d.d_name from department d where d.d_id not in (
select distinct e.d_id from employee e);

有没有其他方法可以做到这一点?。

1 个答案:

答案 0 :(得分:1)

试试这个。

   select department.* from department
     left join employee
       on  employee.d_id = department.d_id
     where employee.d_id is null