出错样例

  1. SELECT last_name
  2. FROM employees
  3. WHERE employee_id NOT IN (
  4. SELECT manager_id
  5. FROM employees
  6. );

查询结果为空,Why?
使用NOT IN并且子查询中含有 manager_id 为null的数据
解决方案:
添加过滤条件。

  1. SELECT last_name
  2. FROM employees
  3. WHERE employee_id NOT IN (
  4. SELECT manager_id
  5. FROM employees
  6. WHERE manager_id IS NOT NULL
  7. );