怎样将Oracle一张表的多个字段更新到另一张表中去

如题所述

�秸疟淼膍obile一样),总结了几种写法。
一、updatea set a.province=(select province from b where b.mobile=a.mobile);
updatea set a.city=(select cityfrom b where b.mobile=a.mobile);
这种写法效率太低,尤其是号码有上万条的时候,所以抛弃。
二、update a set a.province=b.province,a.city=b.city from a inner join b on a.mobile=b.mobile.
或者update a set a.province=b.province,a.city=b.city from a,b where a.mobile=b.mobile.
三、update a inner join b on a.mobile=b.mobile set a.province=b.province,a.city=b.city
注意:第二种和第三种写法在oracle行不通的,老是报错,折腾了好长时间,最后还是用下面的语句解决了问题
四、update a set(a.province,a.city)=(select province,city from b where b.mobile=a.mobile)
其实第四种方法是第一种方法的合并。
项目中写的真实例子:
温馨提示:答案为网友推荐,仅供参考