加入时删除未按预期运行oracle

加入时删除未按预期运行oracle,oracle,join,sql-delete,Oracle,Join,Sql Delete,我很难让我的删除生效。在这种情况下,如果行存在于源表中,我需要基于两列进行删除 我的桌子上有113843行。我的删除声明是: delete from process.designer_mm_px_current_state where exists (select 1 from process.designer_mm_px_current_state dc join process.mm_px_current_state c on dc.soid = c.soid and dc.state_i

我很难让我的删除生效。在这种情况下,如果行存在于源表中,我需要基于两列进行删除

我的桌子上有113843行。我的删除声明是:

delete from process.designer_mm_px_current_state 
where exists (select 1 from process.designer_mm_px_current_state dc
join
process.mm_px_current_state c
on dc.soid = c.soid and dc.state_id = c.state_id)
此报告删除了113843行。但是我插入了一个仅在dc中的新行,因此应该在末尾有一行。此外:

select count(1) from process.designer_mm_px_current_state dc
join
process.mm_px_current_state c
on dc.soid = c.soid and dc.state_id = c.state_id

返回113842行。正如我所料。我错过了什么?我在oracle系统中工作…

您的内部查询和外部查询之间没有引用。试试这个。Dc现在是您的外部参考

delete from process.designer_mm_px_current_state dc
where exists (select 1 from
process.mm_px_current_state c
Where dc.soid = c.soid and dc.state_id = c.state_id)

内部查询和外部查询之间没有引用。试试这个。Dc现在是您的外部参考

delete from process.designer_mm_px_current_state dc
where exists (select 1 from
process.mm_px_current_state c
Where dc.soid = c.soid and dc.state_id = c.state_id)

谢谢你做到了!因此,只要内部查询返回至少一行,内部查询将为外部查询中的每一行返回true,即它存在。。。这就是我做错的吗?你现在明白了…很好,谢谢你做到了!因此,只要内部查询返回至少一行,内部查询将为外部查询中的每一行返回true,即它存在。。。这就是我做错的吗?你现在明白了…很好