Oracle多表关联更新

时间:2021-09-12 13:28:13

错误的解法:

Oracle多表关联更新

正确的解法:

UPDATE
TABLE_ORDER O
SET
O.SETTLE_RATE = ( SELECT
DISTINCT C.SETTLE_RATE
FROM
TABLE_ORDER,
TABLE_CONFIG C
WHERE
O.PAY_ORG_ID = C.PAY_ORG_CODE
)
WHERE
ORDER_ID IN ( SELECT
ORDER_ID
FROM
TABLE_ORDER
WHERE
STATUS = 2
AND ORDER_DATE BETWEEN ‘20160901’
AND ‘20160905’);

Oracle多表关联更新

注意点:在子查询中通过对每条数据进行关联,因而不致于出现了单行子查询返回多个行