我正在oracle中编写update select并得到错误的SQL命令未正确结束。我基本上是基于条件更新经理策略表中的investment_status_id字段。如果我只运行select语句,则运行良好。我的更新声明有什么问题
UPDATE mgr.managerstrategy
SET ms.investment_status_id = mas.investment_status_id
FROM mgr.managerstrategy ms inner join mgr.V_MANAGERSTRATEGY_AUM_SUMMARY mas
ON mas.MANAGERSTRATEGY_ID = ms.ID
WHERE mas.is_invested = 1
选择语句
select * from mgr.managerstrategy ms inner join mgr.V_MANAGERSTRATEGY_AUM_SUMMARY mas
ON mas.MANAGERSTRATEGY_ID = ms.ID
WHERE mas.is_invested = 1
答案 0 :(得分:1)
这是Oracle中的无效语法。 UPDATE
语句不允许使用FROM
子句。
您也许可以使用子查询,如下所示:
UPDATE mgr.managerstrategy ms
SET ms.investment_status_id = (
SELECT mas.investment_status_id
FROM mgr.V_MANAGERSTRATEGY_AUM_SUMMARY mas
WHERE mas.MANAGERSTRATEGY_ID = ms.ID
AND mas.is_invested = 1
)
或者,查看MERGE
语句。