当前位置: 代码迷 >> SQL >> oracle与sql 两表联系关系更新
  详细解决方案

oracle与sql 两表联系关系更新

热度:67   发布时间:2016-05-05 12:57:33.0
oracle与sql 两表关联更新
update T_DestoryBillsDetail  set T_DestoryBillsDetail.wg02=b.wg02,T_DestoryBillsDetail.oldwg10=b.wg10  from T_DestoryBillsDetail a INNER JOIN  gdgl b  on( a.wg00=b.wg00 and a.atype=b.atype collate Chinese_PRC_90_CI_AI) where   a.bid=1211071407220801000 


update a set a.wg02=b.wg02,a.oldwg10=b.wg10  from T_DestoryBillsDetail a,gdgl b where a.wg00=b.wg00 and a.atype=b.atype and a.bid=1211071407220801000 


update a set a.wg02=b.wg02,a.oldwg10=b.wg10  from T_DestoryBillsDetail a,gdgl b where (a.wg00=b.wg00 and a.atype=b.atype  collate Chinese_PRC_90_CI_AI)  and  a.bid=1211071407220801000

sql 2005或者其他低版本数据库,好像经常报无法解决 equal to 操作中 "Chinese_PRC_CI_AS" 和 "Chinese_PRC_90_CI_AI" 之间的排序规则冲突。
所以加上collate Chinese_PRC_90_CI_AI

oracle 写法
update T_DestoryBillsDetail a set (wg02,oldwg10)=(select wg02,wg10 from gdgl b where a.wg00=b.wg00 and a.atype=b.atype ) where exists  (select 1 from gdgl b where b.wg00=a.wg00 and b.atype=a.atype) and a.bid=1211071407220801000
  相关解决方案