有如下3张表:
1. employee员工表:
2.职能表:
3.中间表:,
请编写一条SQL查询语句,查询员工职能只有"开发",没有测试的员工信息
SELECT *
FROM EMPLOYEE M
WHERE NOT EXISTS (SELECT 1
FROM 中间表 T
WHERE M.EID = T.E_ID
AND T.D_ID = '2')
AND EXISTS (SELECT 1
FROM 中间表 T
WHERE M.EID = T.E_ID
AND T.D_ID = '1')
select employee.* from ‘中间表’as z left join 'employee' as e on e.eid=z.e_id left join '职能表' as zn on z.d_id=zn.did where zn.deparment='开发'
select * from employee a where not exists (select 1 from '中间表' b,'职能表' c where a.eid = b.e_id and b.d_id = c.did and c.deparment = '测试');
select eid,`name`
from employee e
inner join `中间表` c
on e.eid=c.e_id
inner join `职能表` d
on c.d_id=d.did
where (
d.deparment='开发'
and e_id not in(
select e_id
from `中间表` c
inner join`职能表` d
on c.d_id=d.did
where d.deparment='测试'
)
);