Oracle SQL:使用同一表的子查询更新Oracle中的多行

  • 本文关键字:Oracle 查询 更新 SQL oracle
  • 更新时间 :
  • 英文 :


我有一个这样的表

<表类> 组 Item_No UL 模型 tbody><<tr>101401010135121013013102空10102空12102空13

我想你在寻找下面:

merge into t1 x
using (select * from t1  where ITEM_NO = 1) y
on (x.M0DEL = y.M0DEL and x.ITEM_NO=2)
WHEN matched THEN
UPDATE SET x.UL=Y.UL -5;

https://livesql.oracle.com/apex/f?p=590:43:20294207843979:::::

update t1 tt1
set tt1.ul=(select tt2.ul from t1 tt2  where  tt1.model1= tt2.model1 and 
tt2.item_no=2)
where tt1.item_no=1;

try this:

MERGE INTO table t1
USING table t2
ON (t1.model = t2.model AND t2.Item_No = 1)
WHEN MATCHED THEN
UPDATE SET t1.UL = t2.UL - 5, t1.Item_No = 2