我这里有两张表,一张是A,一张是B
A的结构如下:
gljg_dm,mc,price,address
B表结构如下:
gljg_dm,address其中A表有10W数据,B表1000数据,要做的是:将B表中的Address更新到A表的Address中,通过gljg_dm关联,这个该如何写呢?
A的结构如下:
gljg_dm,mc,price,address
B表结构如下:
gljg_dm,address其中A表有10W数据,B表1000数据,要做的是:将B表中的Address更新到A表的Address中,通过gljg_dm关联,这个该如何写呢?
where exists(select 1 from tableb c where a.gljg_dm=c.gljg_dm);
where exists(select 1 from tableb c where a.gljg_dm=c.gljg_dm);
merge into A
using B
on(A.gljg_dm=B.gljg_dm)
when matched then
update set A.address=B.address;
update tablea a set a.address=(select b.address from tableb b where a.gljg_dm=b.gljg_dm and a.address<>b.address and rownum=1)
where exists(select 1 from tableb c where a.gljg_dm=c.gljg_dm and a.address<>c.address);
update a set a.address=(select b.address from b where a.gljg_dm=b.gljg_dm and rownum=1)
where exists(select 1 from b C where a.gljg_dm=C.gljg_dm);