oracle delete from t_da_inst_item_appr t inner join t_da_sum_inst_item i on t.inst_id = i.inst_id where i.task_id = 'DraftImport_SubjectData' and i.task_inst_id = '20230713966820' and i.flag = 'D' and exists (select 1 from t_da_sum_inst s where s.INST_ID = i.parent_id and s.STATUS in ('03', '04', '06', '08') and s.task_id = i.task_id and s.task_inst_id = i.task_inst_id);
时间: 2024-04-14 19:27:10 浏览: 140
很抱歉,我之前给出的回答有误。Oracle 不支持使用 INNER JOIN 在 DELETE 语句中进行连接操作。相反,你可以使用子查询来实现相同的功能。以下是修改后的 SQL 查询语句:
```
DELETE FROM t_da_inst_item_appr
WHERE inst_id IN (
SELECT t.inst_id
FROM t_da_inst_item_appr t
INNER JOIN t_da_sum_inst_item i ON t.inst_id = i.inst_id
WHERE i.task_id = 'DraftImport_SubjectData'
AND i.task_inst_id = '20230713966820'
AND i.flag = 'D'
AND EXISTS (
SELECT 1
FROM t_da_sum_inst s
WHERE s.INST_ID = i.parent_id
AND s.STATUS IN ('03', '04', '06', '08')
AND s.task_id = i.task_id
AND s.task_inst_id = i.task_inst_id
)
);
```
这个修改后的查询语句使用子查询来获取满足条件的 inst_id,并将这些 inst_id 用于 DELETE 语句中进行删除操作。请注意,在执行 DELETE 操作前,请务必备份数据,以防止意外删除数据。同样,也需要根据实际情况进行调整和优化,并确保查询的准确性和性能。
阅读全文
相关推荐



















