-2

我有两张表,一张是原始表,第二张是临时表。具有正确记录的临时表。唯一列是 cust_id。我的表结构是

客户表

cust_id  amount
12       100
13       120
14       130
15       250
20        70
25       110
28       900

temp table 

cust_id  amount
12       300
13       190
14       110
15       240
20        30
25       210
28       500

我想使用客户 ID 将记录从临时表更新到客户原始表。

4

1 回答 1

1

可以使用合并语句来完成。

merge into original_table ot
using temp_table tp
  on (ot.cust_id = tp.cust_id)
when matched 
then update set ot.amount = tp. amount
于 2013-07-22T14:04:37.943 回答