ORACLE 使用 order by 进行 UPDATE 交易

问题描述 投票:0回答:1
I need to update a table by using "order by". Because I am updating line |numbers by a group of   columns. But I have an paranthese error. The thing is that there is no paranthese error. I do not understand why my oracle transact sql code is not functionning.
UPDATE SET_MYIG a set "LINEID" = (SELECT b."LINEID"
FROM SET_MYIG_UPDATE_LINEID b 
WHERE  a."Fil1"=b.Filler1
and a."Fil2"=b.Fil2 
and a."Fil3"=b.Fil3 and a."Fil4"=b.Fil4 
and a."Fil5"=b.Fil5 
order by b."LineID");

SET_MYIG_UPDATE_LINEID 用 Rownum 初始化,然后我必须更新表

oracle11g sql-update sql-order-by
1个回答
0
投票

我需要使用“order by”更新表格。

ORDER BY
在 Oracle 期望返回包含标量值的单行的子查询中不是有效语法,因为当您返回单行时,
ORDER BY
毫无意义。

如果您的子查询确实返回单个值,则只需删除

ORDER BY
子句:

UPDATE SET_MYIG a
set LINEID = ( SELECT b.LINEID
               FROM   SET_MYIG_UPDATE_LINEID b 
               WHERE  a."Fil1"=b.Filler1
               and    a."Fil2"=b.Fil2 
               and    a."Fil3"=b.Fil3
               and    a."Fil4"=b.Fil4 
               and a."Fil5"=b.Fil5 
             );
© www.soinside.com 2019 - 2024. All rights reserved.