update tb1 t1 set t1.var=(select t2.var from tab2 t2 where t2.id=t1.id);

解决方案 »

  1.   

    update tb1 set var=(select max(var) from tb2 where tb1.id=tb2.id)
    where exists (select var from tb2 where tb1.id=tb2.id);
      

  2.   

    update tb1 t1 set t1.var=(select t2.var from tab2 t2 where t2.id=t1.id)
    where exists (select 1 from tb2 where t2.id=t1.id);
      

  3.   

    update tb1 t1 set t1.var=(select t2.var from tb2 t2 where t2.id=t1.id)
    where exists (select id from tb2 where t2.id=t1.id);
      

  4.   

    update tb1 t1 set t1.var=(select t2.var from tab2 t2 where t2.id=t1.id) where t1.id in (select id from t2)