SQL> DELETE FROM employees WHERE employee_id = (SELECT employee_id FROM new_emp);
DELETE FROM employees WHERE employee_id = (SELECT employee_id FROM new_emp)
ORA-01427: single-row subquery returns more than one row
为什么报错呢?
------解决方案--------------------------------------------------------
DELETE FROM employees WHERE employee_id in (SELECT employee_id FROM new_emp)
因为子查询SELECT employee_id FROM new_emp返回多于一个的结果集
------解决方案--------------------------------------------------------
不能用等值,等值存在一对多的关系,只能用IN
DELETE FROM employees WHERE employee_id IN (SELECT employee_id FROM new_emp);