update 学生成绩表A set 语文 = sum(select 语文 from 其他表 where 学号=学生成绩表A.学号) 数学 = sum(select 数学 from 其他表 where 学号=学生成绩表A.学号) 英语 = sum(select 英语 from 其他表 where 学号=学生成绩表A.学号)
update 学生成绩表A set 语文 = isnull(sum(select 语文 from 其他表 where 学号=学生成绩表A.学号),0) 数学 = isnull(sum(select 数学 from 其他表 where 学号=学生成绩表A.学号),0) 英语 = isnull(sum(select 英语 from 其他表 where 学号=学生成绩表A.学号),0) 如果其他表没有学号,默认为0分
set 语文 = b.语文,
数学 = b.数学,
英语 = b.英语
from 学生成绩表A a, 其他表 b
where a.学号 = b.学号
set 语文= b.语文, 数学 = b.数学, 英语 = b.英语
from tablename b
where a.学号 = b.学号
update A set A.语文=其他表.语文,A.数学=其他表.数学,A.英语=其他表.英语
where A.学号=其他表.学号???
A.数学=其他表.数学,
A.英语=其他表.英语
from 其他表
where A.学号=其他表.学号
该成绩 需要在其他各个过程中返回
即
0787 执行过程PROC1 返回 各个科目成绩
学生成绩表A
学号 语文 数学 英语
0787
0785
0783
...
nnnn
---------------
存储过程B
传入参数 @学号
.........
更新成绩表A相应字段
-----------------
求 更新A的所有记录
set 语文 = sum(select 语文 from 其他表 where 学号=学生成绩表A.学号)
数学 = sum(select 数学 from 其他表 where 学号=学生成绩表A.学号)
英语 = sum(select 英语 from 其他表 where 学号=学生成绩表A.学号)
set 语文 = isnull(sum(select 语文 from 其他表 where 学号=学生成绩表A.学号),0)
数学 = isnull(sum(select 数学 from 其他表 where 学号=学生成绩表A.学号),0)
英语 = isnull(sum(select 英语 from 其他表 where 学号=学生成绩表A.学号),0)
如果其他表没有学号,默认为0分