t1
-----------------------
id    A      B      Ct2
---------------------
id    F如果满足条件:t1.id = t2.id ,  t1.B = '0', F = null
就把F的值设置为C
请问如何实现 ?

解决方案 »

  1.   

    update t2 set t2.XX='F' from t1,f2 where t1.id = t2.id and  t1.B = '0' and F = null
      

  2.   

    update t2 set t2.F='C' from t1,f2 where t1.id = t2.id and  t1.B = '0' and F IS null 才行; Null是不能用‘=’的
      

  3.   

    update t2 set t2.F=(select t1.C from t1 where t1.id = t2.id  and  t1.B = '0' and t2.F IS null )
      

  4.   

    update t2 b
    set b.f = 
    (select a.c from t1 a
     where a.id = b.id and b.b<>0 and a.f is null
    )