码迷,mamicode.com
首页 > 数据库 > 详细

oracle中Update方法

时间:2016-06-25 12:17:18      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:

1、两表(多表)关联update -- 被修改值由另一个表运算而来

  update customers a

  set city_name=(select b.city_name from tmp_cust_city b where b.customer_id=a.customer_id)

  where exists (select 1

  from tmp_cust_city b

  where b.customer_id=a.customer_id)

  实例: 

  update bd_psndoc
  set bd_psndoc.indutydate=(select begindate from (select a.pk_psnbasdoc as pk_psnbasdoc,
  max(b.begindate) as begindate
  from temp_psnbasdoc a left join hi_psndoc_deptchg b
  on a.pk_psnbasdoc=b.pk_psnbasdoc and a.recordnum=b.recordnum
  group by a.pk_psnbasdoc) tt where tt.pk_psnbasdoc=bd_psndoc.pk_psnbasdoc)
  where exists(select 1 from (select a.pk_psnbasdoc as pk_psnbasdoc,
  max(b.begindate) as begindate
  from temp_psnbasdoc a left join hi_psndoc_deptchg b
  on a.pk_psnbasdoc=b.pk_psnbasdoc and a.recordnum=b.recordnum
  group by a.pk_psnbasdoc) tt where tt.pk_psnbasdoc=bd_psndoc.pk_psnbasdoc)
  and pk_psncl=‘00015T100000000003M2‘ and indutydate is null

oracle中Update方法

标签:

原文地址:http://www.cnblogs.com/zll-20140222/p/5616085.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!