我这里有两张表,一张是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);
where exists(select 1 from tableb c where a.gljg_dm=c.gljg_dm);更新不都是这样写的吗?新手呵呵
update a set a.address(=select address from b where a.gljg_dm=b.gljg_dm and rownum=1)
where exists(select 1 from b where a.gljg_dm=b.gljg_dm)
--or(9i 以上 推荐)merge into a using b on(a.gljg_dm=b.gljg_dm)
when matched then
update set a.address=b.address
有 要是没有匹配 的 会被更新为null
update a set a.address(=select address from b where a.gljg_dm=b.gljg_dm and rownum=1)
where exists(select 1 from b where a.gljg_dm=b.gljg_dm)
--or(9i 以上 推荐)merge into a using b on(a.gljg_dm=b.gljg_dm)
when matched then
update set a.address=b.address