有如下两张表:
A(ID, B_ID, Detail)
B(ID, Cnt)
B.Cnt为计数值,值为Select Count(*) As ACnt, B_ID From A Group By B_ID得到的ACnt求一段命令,能用来更新B.Cnt的值,谢谢。

解决方案 »

  1.   

    update B set Cnt=C.ACnt From (Select Count(*) As ACnt, B_ID From A Group By B_ID)C where ID=B_ID
      

  2.   

    Update B Set Cnt=(Select Count(*) from A where A.B_ID=B.ID) 
      

  3.   

    update B set Cnt=C.ACnt From (Select Count(*) As ACnt, B_ID From A Group By B_ID) C where B.ID=C.B_ID
      

  4.   

    是用insert,你目的都没有搞清楚吧?update 前面的就可以了!
      

  5.   

    Update B set Cnt=tmp.ACnt from B inner join 
    (Select Count(*) As ACnt, B_ID From A Group By B_ID) tmp on B.ID=tmp.B_ID
      

  6.   

    selelc t ds d g f sdf sdf fg gh df gd fsdfsdf sf ew r er s f tres f sdfrt se  sdfs d fsdf sdfs df sdfg dgdf gre t sdf sdrewr sdf we f sdf esf