这里有些问题,如果我们想找出没有请假记录的员工,应该使用右连接(right join)而不是左连接(left join),因为我们需要保留所有员工记录,但是只对请假记录进行匹配。

正确的查询语句应该是:

SELECT e.empid, e.ename FROM emp e RIGHT JOIN holiday h ON e.empid = h.empid WHERE h.empid IS NULL;

select eempideename from emp e left join holiday h on eempid=hempid where eempid is null;改正

原文地址: http://www.cveoy.top/t/topic/ghUo 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录