sql语句联表更新(从一个数据库中的一张表更新到另一个数据库的另一张表)

时间:2015-03-12 22:19:32   收藏:0   阅读:5819

一、sql server数据库写法:

update a set a.ksgmm=b.ksgmm,a.ksgm=b.ksgm,a.scztm=b.scztm,a.sczt=b.sczt from landsde.sde.jszb a,kyqcldb.dbo.kcl_ksjj b 
where a.nd=b.nd and a.kqbh=b.kqbh and a.djflbh =b.djflbh

其中landsde.sde.jszb、kyqcldb.dbo.kcl_ksjj是不同数据库下的不同数据表

 

二、oracle写法

update usertab a set (a.name, a.age)= (select b.name, b.age from member b where a.id=b.id)

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!