exists 后的子查询要是有值就return true,子查询结果为null就return false。通过将子查询和主查询连接,我们因此通过not exists将主查询结果限制为能让子查询结果为空的行。

select * from employees as e
where not exists (select dept_no from dept_emp as de
                  where e.emp_no = de.emp_no)