日期:2014-05-17  浏览次数:20871 次

问下这个语句怎么写啊、????着急 在线等!!!!!!
表A(ID1,VALUE)
表B(ID2,ID3)

描述:我想批量更新表A的所有value字段, 如果ID1=ID2, 就把 id3更新到value字段


常规方法:
update a
set a.value= (select id3 from b where a.id1 = b.id2)
where exists (select 1 from b where a.id1 = b.id2 )

但是表中的数据有几千万,,,到不过来的,,,请问能不能用循环更新1000个提交一次a ???


SQL语句应该怎么写啊?

------解决方案--------------------
过程的语法错误,我看到你另外发贴了,就不说了,
你这样循环,效率比单个update语句更差的。
------解决方案--------------------
SQL code

--加这句比较好,毕竟你不是所有的都需要更新
update a
set a.value= (select id3 from b where a.id1 = b.id2)
where exists (select 1 from b where a.id1 = b.id2 and a.value<>b.value)