exists / not exists : 存在/不存在,即将外表(employees表)的字段(emp_no)代入子查询(内表)中看是否成立/不成立。
select a.emp_no,a.birth_date,a.first_name,a.last_name,a.gender,a.hire_date from employees a where not exists (select emp_no from dept_emp b where b.emp_no = a.emp_no);
直接外联结
select a.emp_no,a.birth_date,a.first_name,a.last_name,a.gender,a.hire_date from employees a left join dept_emp b on a.emp_no = b.emp_no where b.dept_no is null;