1.用户提供了一份学生异动数据。
分析:a.在系统里面学生所对应的班级,专业,学院这些基础数据都是存在的,我只需要把学生的班级在数据库里面弄准确即可。
b.处理这些数据那我要知道我应该处理那几张表(这个需要基于对系统的数据结构有所了解),那么我处理数据需要牵涉到四张表(学院部门信息表(bmdmb),学生信息表xsxxb,专业代码表zydmb,班级代码表bjdmb)
c.由于用户提供的是execl,我只要建一张临时表temp,将我需要的字段拷贝到临时表,那么我抽取两项有用的字段,学生学号,和学生所在班级名称即可根据这个字段关联修改数据。
select *from xsxx where xh='15163612' ;
select *from bjdm where bjdm='163A1506' or bjmc='数15(7)数学S卓越' or bjmc='外15(1)英语S';(确认数据是否存在)
create table temp (
xh varchar2(45),
bjmc varchar2(90)
)
select * from temp for update;
select *from zydm
select *from xsxx where xh in(select xh from temp);
select *from bjdm where bjmc in(select bjmc from temp)
update xsxx a set bjmc=(select bjmc from temp b where a.xh=b.xh) where xh in(select xh from temp);
update xsxx a set bjdm=(select bjdm from bjdm b where a.bjmc=b.bjmc) where xh in(select xh from temp);
update xsxx a set zydm=(select zydm from bjdm b where a.bjdm=b.bjdm) where xh in(select xh from temp);
update xsxx a set xydm=(select bmdm from zydm b where a.zydm=b.zydm) where xh in(select xh from temp);
update xsxx a set bjdm=(select bjdm from bjdm b where a.bjmc=b.bjmc) where xh in(select xh from temp);
update xsxx a set zydm=(select zydm from bjdm b where a.bjdm=b.bjdm) where xh in(select xh from temp);
update xsxx a set xydm=(select bmdm from zydm b where a.zydm=b.zydm) where xh in(select xh from temp);