Sql Server 与 Oracle 的多表提交

sql server 语法 :

  update a  set a.jhjg = b.jhjg from yk_ck02 a,yk_ypcd b where a.ypxh=b.ypxh and a.ypcd = b.ypcd and a.xtsb = 2 and a.ckdh = 100028 and a.ckfs=12 and a.jhjg = 0

 

Oracle 语法:

    update tab1 a set (a.col1, a.col2)= (select b.col_1, b.col_2 from tab2 b where a.col3=b.col_3)

    将tab1表 col1,col2的值全部更新,更新的值为select b.col_1, b.col_2from tab2 b where a.col3=b.col_3,注意:如果tab1 a中有a.col3 !=b.col_3的记录,

col1,col2字段将更新为空值,如果col1,col2字段不允许为空,sql语句执行会出错,SQL语句 应改为:

     update tab1 a set (a.col1, a.col2)= (select b.col_1, b.col_2 from tab2 b where a.col3=b.col_3) where exists (select 1 from tab2 b where a.col3=b.col_3)

 

MySQL 示例: update landleveldata a, gdqlpj b set a.gqdltks= b.gqdltks, a.bztks= b.bztks where a.GEO_Code=b.lxqdm

原文地址:https://www.cnblogs.com/rxie/p/2461195.html