oracle关联更新

 业务场景中需要对特定数据进行关联更新,记录一下关联更新语法:

MERGE INTO fine_record_execute targ
USING (
    SELECT "id","tname"
    FROM fine_record_execute
    WHERE "username" LIKE '%目标人物%'
        AND "time">='2020-08-03'
        AND "time"<='2020-08-06'
) msrc ON (msrc."id" = targ."id")
WHEN MATCHED THEN UPDATE
SET targ."param" = msrc."tname"--,targ."consume"=msrc."tname"
--WHEN NOT MATCHED THEN INSERT  
--VALUES (msrc.param, msrc."consume", np.category)  
--WHERE msrc.username NOT LIKE '%目标人物%'

你可能感兴趣的:(数据库,数据库,服务器)