This query will select all employees (e.empid and e.ename) who did not take any holidays (left join with holiday table where empid is null).

However, the logic of this query is incorrect. If an employee did take a holiday, their empid will not be null in the holiday table and therefore the left join will not return null. To get all employees who did not take a holiday, the query should be:

SELECT e.empid, e.ename FROM emp e LEFT 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/ghT6 著作权归作者所有。请勿转载和采集!

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