exists是个条件判定,是不会返true or false.
update hzk a set a.mcnbxh = ( select b.newdata from temp_xdata b where b.userid = 1 and b.colname = 'mcxh' and a.mcnbxh = b.olddata )
这样就可以了。

解决方案 »

  1.   

    但是这样会把hzk中部满足不需要更新的纪录给更新了
      

  2.   

    在exists中要用另外的别名,你试试下面的语句
    update hzk a set a.mcnbxh = ( select b.newdata from temp_xdata b where b.userid = 1 and b.colname = 'mcxh' and a.mcnbxh = b.olddata ) 
    where exists(select 1 from temp_xdata c where c.userid = 1 and c.colname = 'mcxh' and a.mcnbxh = c.olddata );