晕, 一样的动不动有什么区别吗?方式1, updateupdate a set a.qty = (select qty from b where a.id = b.id) where exists (select 1 from b where a.id = b.id and a.qty <> b.qty)
方式2, merge intomerge into a using (select b.* from a, b where a.id = b.id and a.qty <> b.qty ) b on (a.id = b.id) when matched then update set a.qty = b.qty when not matched then insert (a.id,a.qty) values(b.id,b.qty)
merge into B using A on(B.id = a.id) when matched then update set B.QTY=A.QTY where B.QTY<>A.QTY;
update a set a.qty = (select qty from b where a.id = b.id) where exists (select 1 from b where a.id = b.id and a.qty <> b.qty)
都可以。一个是没有找到的情况下就为insert一条建议2楼
merge into B using A on(B.id = a.id) when matched then update set B.QTY=A.QTY where B.QTY<>A.QTY;
set a.qty = (select qty from b where a.id = b.id)
where exists (select 1 from b where a.id = b.id and a.qty <> b.qty)
using (select b.* from a, b where a.id = b.id and a.qty <> b.qty ) b
on (a.id = b.id)
when matched then
update set a.qty = b.qty
when not matched then
insert (a.id,a.qty)
values(b.id,b.qty)
merge into B
using A
on(B.id = a.id)
when matched then
update set B.QTY=A.QTY where B.QTY<>A.QTY;
set a.qty = (select qty from b where a.id = b.id)
where exists (select 1 from b where a.id = b.id and a.qty <> b.qty)
using A
on(B.id = a.id)
when matched then
update set B.QTY=A.QTY where B.QTY<>A.QTY;