过着简单,真实的生活,喜欢收藏变形金刚(TFE,G1,SL系列),研究金融股市,KOF98,篮球,学习研究Oracle技术,我并不是一个全职的Oracle DBA,但是对于Oracle技术的热爱和研究,是一个不争的事实,愿意结交广大Oracle技术爱好者!MSN:oracle_kof_tf@hotmail.com

Update 多个关联表SQL的写法

上一篇 / 下一篇  2007-12-10 18:49:58 / 个人分类:Oracle数据库技术-SQL

更新一列:
update mytab a set name=(select b.name from goal b where b.id=a.id)
where exists (select 1 from goal b where b.id=a.id);

更新多列:
update mytab a 
   set  (name,address)=(select b.name,b.address 
                                     from   goal b
                                     where  b.id=a.id)
   where  exists (select 1
                  from goal b
                  where  b.id=a.id )

特别是要注意exists后面的语句:)这会让目标行不至于为NULL


TAG:

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

Open Toolbar