注册 登录
编程论坛 SQL Server论坛

[求助]更新两个表中的数据该怎么办呢??

哑哑。。 发布于 2006-10-04 16:01, 509 次点击
是有关毕业设计的成绩的数据库
我现在有两个表。。一个表是submaintscore..里面有五个字段分别是isright ,literature,exhibition,individual,desire。。。另一个表是submaintscoreall..里面有一个字段是submaintscore是前面那个表中的五个字段的和。。。
现在我要更新submaintscore中的字段。。但是要求submaintscoreall中的也要更新。。要怎么办呀。。
2 回复
#2
潇洒老乌龟2006-10-04 21:31
假设ID为两表关联字段
update submaintscore
set isright = ? ,
literature =?,
exhibition = ?,
individual =?,
desire = ?
where ....

update submaintscoreall
set submaintscore = b.isright + b.literature + b.exhibition + b.individual + b.desire
from submaintscoreall as a , submaintscore as b
where a.id = b.id
#3
LouisXIV2006-10-06 07:55

自行查询帮助文件中的触发器(Trigger)

1