【发布时间】:2011-09-15 10:20:10
【问题描述】:
我有一个要求,我希望根据表 A 中的条件选择行,并且必须删除表 B。
例如 EMP 和 EMP1 是两个表
Merge into emp1 a
using (select * from emp) b
on (a. empno =b.empno)
WHEN MATCHED THEN DELETE
where(b.LOC='NEW YORK');
上述查询导致错误。
如果我使用Where exists,则表A中的所有行都会被删除,这不是正确的解决方案。
delete from emp1 a
where exists
( select null
from emp b
where a. empno =b.empno
and b.LOC='NEW YORK'
);
请推荐
【问题讨论】:
标签: sql oracle oracle10g oracle11g