如果XM是唯一的那么应该不是一件很困难的事
如果科目也是已知的,我想一句话就可以了
如果成绩单口中已有人员信息,(更新)
update m
set m.fs1=a.fs
,m.fs2=b.fs
,m.fs3=c.fs
from ReportCard m
left outer join subject1 a on m.xm=a.xm
left outer join subject2 b on m.xm=b.xm
left outer join subject3 c on m.xm=c.xm
如果成绩单中没有人员信息,则
insert into ReportCard(xm,fs1,fs2,fs3)
select m.xm,a.fs,b.fs,c.fs
from ReportCard m
left outer join subject1 a on m.xm=a.xm
left outer join subject2 b on m.xm=b.xm
left outer join subject3 c on m.xm=c.xm
如果成绩单表不存在
select m.xm,a.fs as fs1 ,b.fs as fs2,c.fs as fs3
into ReportCard
from ReportCard m
left outer join subject1 a on m.xm=a.xm
left outer join subject2 b on m.xm=b.xm
left outer join subject3 c on m.xm=c.xm