例如表User
ID Name Dep Team
1 A 1 1
2 B 1 2现在有某个表CostID UserID dep team cost
1 1 2 2 100
2 2 1 1 100如果按照User表的dep 和team来更新cost,这条sql如何写呢..?
谢谢
ID Name Dep Team
1 A 1 1
2 B 1 2现在有某个表CostID UserID dep team cost
1 1 2 2 100
2 2 1 1 100如果按照User表的dep 和team来更新cost,这条sql如何写呢..?
谢谢
set dep=u.dep,Team=u.Team from User u where u.id=Cost.UserId
dep = u.dep,team = u.team
from cost c,user u
where c.userid = u.id
1、第二个表的表名是什么?
2、更新cost,是用外部信息,还是用User表中的信息
3、User表和第二个表的关联关系