现在有两个表
table1 table2
ID line product price ID line price
1 1 a 1 1 12.00
1 2 b 1 2 12.00
2 1 c 2 1 6.00
2 2 d 2 2 7.00
3 1 a 3 1 10.00
3 2 c 3 2 9.00
3 3 f 3 3 7.00
4 1 g其中ID和line能确定唯一行,现在怎么把table2的price,对应更新到talbe1的price字段?
table1 table2
ID line product price ID line price
1 1 a 1 1 12.00
1 2 b 1 2 12.00
2 1 c 2 1 6.00
2 2 d 2 2 7.00
3 1 a 3 1 10.00
3 2 c 3 2 9.00
3 3 f 3 3 7.00
4 1 g其中ID和line能确定唯一行,现在怎么把table2的price,对应更新到talbe1的price字段?
update a
set a.price = b.price
from table1 a,table2 b
where a.id = b.id and a.line = b.line