我有三张表。
表A,表B,表C
表A的字段如下:
ID
UserName
Store
Point表B的字段如下:
ID
UserName
Store_B
Point_B表C的字段如下:
ID
UserName
Store_C
Point_C表A的Store为表B和表C相应字段的总和,即A.Store=B.Store_B+C.Store_C;A.Point=B.Point_B+C.Point_C条件是相应更新每个UserName相应的Store和Point值?

解决方案 »

  1.   

    update 表A
    set A.Store=B.Store_B+C.Store_C,A.Point=B.Point_B+C.Point_C
    from 表A A,表B B,表C C
    where A.UserName = B.UserName and A.UserName = C.UserName
      

  2.   

    修改一下:
    update A
    set A.Store=B.Store_B+C.Store_C,A.Point=B.Point_B+C.Point_C
    from 表A A,表B B,表C C
    where A.UserName = B.UserName and A.UserName = C.UserName