类似于这个样子:
一主表,一从表,通过fid关联,现在想把主表某列的值付到从表里去,从表数据是要多于主表的,(从表为0的付)
类似于下面
update t_BOS200000003entry2 t1 set fbase=
(select fdptid from t_BOS200000003 t) 
where  t.fid=t1.fid and t1.fbase<>0不知道说明白没,求update语句,谢了

解决方案 »

  1.   

    这写错了t1.fbase=0
    就从表这列如果有值,就不用update,=0的update
      

  2.   


    update t_BOS200000003entry2 t1 set fbase=
    (select fdptid from t_BOS200000003 t  WHERE t1.fid=t.fid)  
    where t1.fbase<>0
      

  3.   

    update t1 set fbase=fdptid 
    from t_BOS200000003entry2 t1 join t_BOS200000003 t2
    on t1.fid=t2.fid where t1.fbase=0
      

  4.   

    update t_BOS200000003entry2 set fbase=t.fdptid from t_BOS200000003 t
    where where t.fid=t1.fid and t1.fbase<>0