我们经常用的是NOT IN + 子查询select emp_no from employees where emp_no not in (select emp_no from dept_manager);
但是还可以用LEFT JOIN 的思路SELECT e.emp_no FROM employees AS e LEFT JOIN dept_manager AS d ON e.emp_no=d.emp_no WHERE dept_no IS NULL;
2024-04-03 11:47:47
我们经常用的是NOT IN + 子查询select emp_no from employees where emp_no not in (select emp_no from dept_manager);
但是还可以用LEFT JOIN 的思路SELECT e.emp_no FROM employees AS e LEFT JOIN dept_manager AS d ON e.emp_no=d.emp_no WHERE dept_no IS NULL;
下一篇:MySQL中的基本SQL语句