出错样例
SELECT last_name
FROM employees
WHERE employee_id NOT IN (
SELECT manager_id
FROM employees
);
查询结果为空,Why?
使用NOT IN并且子查询中含有 manager_id 为null的数据。
解决方案:
添加过滤条件。
SELECT last_name
FROM employees
WHERE employee_id NOT IN (
SELECT manager_id
FROM employees
WHERE manager_id IS NOT NULL
);