我有一个关于oracle sql的问题。所以我想要的是根据另一个表中的相同事件更新一个表中的列。这是我的sql
update master_drawing
set master_drawing.subcont_status = 'ASSIGNED'
where master_drawing.head_mark = master_drawing_assigned.head_mark
因此,在MASTER_DRAWING
和MASTER_DRAWING_ASSIGNED
中,有两个完全相同的列名为HEAD_MARK
。我想做的就像一张支票。如果在这两个表中存在相同的值,则使用SUBCONT_STATUS
'ASSIGNED'
,错误信息为:
[错误]执行(1:103):ORA-00904:“MASTER_DRAWING_ASSIGNED”。“HEAD_MARK”:标识符无效
请帮助我。
答案 0 :(得分:1)
试试这个:
UPDATE md
SET md.subcont_status = 'ASSIGNED'
FROM master_drawing md
INNER JOIN master_drawing_assigned mda ON md.head_mark = mda.head_mark;
答案 1 :(得分:1)
试试这个:
update master_drawing md
set md.subcont_status = "ASSIGNED"
where exists
(select 1
from master_drawing_assigned mda
where md.head_mark = mda.head_mark)