比如我想更新g3表,在g32006表的总额字段>100000时 让g3表的test=4,怎么写?
这2个表都有w1(工号)字段,g3表的记录比g32006的记录要多。但我只需要更新g32006表中有的数据

解决方案 »

  1.   

    try
    Update A 
    Set test=4
    From g3 A Inner Join g32006 B
    On A.w1 = B.w1
    Where B.总额>100000
      

  2.   

    或者Update A 
    Set test=4
    From g3 A , g32006 B
    Where A.w1 = B.w1
    And B.总额>100000
      

  3.   

    update g3
    set test=4
    from g3,g32006
    where g3.w1=g32006.w1
    and g32006.总额>100000
      

  4.   

    update b set test=4 from g32006 a,g3 b where a.w1=b.w1 and qa.总额字段>100000
      

  5.   

    update g3
    set g3.test=4
    from g3,g32006
    where g3.w1=g32006.w1 and g3.总额>100000
      

  6.   

    create trigger on g32006 for  INSERT, UPDATE
    AS
    if (select sum(总额) from g32006 ) >100000
    update g3 set test=4
      

  7.   

    Update a
    Set a.test=4
    From g3 a , g32006 b
    Where a.w1 = b.w1
    And b.总额>100000
      

  8.   

    打多了个字update b set test=4 
    from g32006 a,g3 b 
    where a.w1=b.w1 and a.总额字段>100000
      

  9.   

    是g32006.总额>100000楼上都这么答案了!!
      

  10.   


    update g3 set test=4 from g3,g32006 where g3.w1=g32006.w1 and g32006.总额>100000