例子1:
delete from table1 a where exists (select 1 from table2 b where a.id=b.id)
例子2:
rebatepolicy表是主表,rebatepolicyitems是从表,从表有主表的主键,现在对于主表一些条件的数据的对应子表要求删除。
如下方式:
delete from rebatepolicyitems rs where exists
(
select 1
from rebatepolicy r where rs.rebateguid=r.rebateguid
and to_char(r.createdate,'yyyyMMdd')='' and r.creator='名字'
)
delete from table1 a where exists (select 1 from table2 b where a.id=b.id)