跨两个表删除整行(内连接?)

时间:2011-08-19 18:09:07

标签: sql oracle sql-delete

我正在尝试跨两个表删除一行数据。我有以下代码无效:

DELETE
FROM PROCESS_OWNER.ARTIFACTS
JOIN PROCESS_OWNER.ARTIFACT_METADATA
ON ARTIFACTS.ARTIFACT_ID = ARTIFACT_METADATA.ARTIFACT_ID
WHERE ARTIFACT_LABEL = 'getTest'

我收到错误消息:

  

“SQL命令未正确结束”

当我努力想要掌握Oracle时,真的会感激一些帮助。

1 个答案:

答案 0 :(得分:1)

你不能通过加入来做到这一点。 DELETE FROM必须以单个表为目标。你可以这样做:

DELETE FROM PROCESS_OWNER.ARTIFACT_METADATA WHERE ARTIFACT_ID = (SELECT ARTIFACT_ID FROM PROCESS_OWNER.ARTIFACTS WHERE ARTIFACT_LABEL = 'getTest');
DELETE FROM PROCESS_OWNER.ARTIFACTS WHERE ARTIFACT_LABEL = 'getTest';