使用 oracle 中表 2 的数据更新表 1

问题描述 投票:0回答:1

同事们下午好,我在使用另一个表中的信息更新数据的查询时遇到问题。

UPDATE TPR
SET TPR.doxa = result.doxa 
FROM TABLA1 TPR 
INNER JOIN (
    SELECT t1.S, t1.D) AS doxa
    FROM TABLA1 t1 
    INNER JOIN TABLA2 t2 ON t1.S = t2.D 
) result ON c.S = result.S
WHERE TPR.S = result.S;

命令的第 18 行开始出错 -

UPDATE TPR
SET TPR.doxa = result.doxa
FROM TABLE1 TPR
INNER JOIN (
    SELECT t1.S, t1.D) AS doxa
    FROM TABLE1 t1
    INNER JOIN TABLE2 t2 ON t1.S = t2.D
) result ON c.S = result.S
WHERE TPR.S = result.S
Command line error: 20 Column: 1
Bug Report -
SQL Error: ORA-00933: SQL command not completed correctly
00933. 00000 - "SQL command not properly ended"
*Cause:
*Action:

有人可以帮助我解决我做错的事情或者是否还有其他方法?

oracle oracle-sqldeveloper
1个回答
0
投票

我会切换到

merge

merge into tpr
using (select t1.s, 
              t1.d as doxa
       from tabla1 t1 join tabla2 t2 on t1.s = t2.d
      ) result
on (result.s = tpr.s)
when matched then update set
  tpr.doxa = result.doxa;
© www.soinside.com 2019 - 2024. All rights reserved.