Oracle中用一个表的数据更新另一个表的数据

update tbl1 a
   set (a.col1, a.col2) = (select b.col1, b.col2
                              from tbl2 b
                              where a.key = b.key)
   where a.key in(select key from tbl2)

 

 

UPDATE table1 t1
   SET (name, desc) = (SELECT t2.name, t2.desc
                         FROM table2 t2
                        WHERE t1.id = t2.id)
 WHERE EXISTS (
    SELECT 1
      FROM table2 t2
     WHERE t1.id = t2.id )

posted @ 2014-08-31 18:09  emanlee  阅读(731)  评论(0编辑  收藏  举报