您的位置:首页 > 其它

处理驾校学员系统编号重复的问题

2014-06-06 17:34 78 查看
--1、检查学员编号重复的情况(非手工编号,手工编号对应TEMPXH,学员编号对应CXYBH)

--修改学员资料均是以学员编号为准的

--按理说学员编号是不允许重复的,重复是不能保存的

--只有一种可能就是当初手工调整过学员编号

select * from ec_xueyuan where cxybh in(select cxybh from ec_xueyuan where cxybh<>'' group by cxybh having(count(cxybh))>1) order by cxybh desc

--注意输出重复的学员编号,以便更新收费信息和考试信息

--2、列出重复中最大的序号的那个,注意第一步查询出来后先导出信息

select * from ec_xueyuan where xh in (select max(xh) from ec_xueyuan group by cxybh having count(cxybh)>1)

--3、更新学员编号,将序号最大的那个加个00

update ec_xueyuan set cxybh='00'+cxybh where xh in (select max(xh) from ec_xueyuan group by cxybh having count(cxybh)>1)

--update ec_xueyuan set cxybh='0155325' where xh=41513

--4、更新学员收费信息,查找收费信息只更新最后的那个收费,实在无法区分的话,此步省去

select * from ec_shoufei where cxybh='042149'

update ec_shoufei set cxybh='00'+cxybh where xh=38785

--5、更新学员考试成绩,注意区分更新那个,实在无法区分的话,此步省去

select * from ec_chengji where cxybh='042149'

update ec_chengji set cxybh='00'+cxybh where xh=387

--以下查询语句无实际意义=========

--列出重复的学员编号资料

select * from ec_xueyuan where cxybh like '%042149%' order by xh

--手工更新学员编号,将序号最大的那个加个00

update ec_xueyuan set cxybh='00'+cxybh where xh=5553

--检查手工编号重复的情况,手工编号重复系统是允许保存的,只要学员编号不重复系统允许

select * from ec_xueyuan where ctempbh in(select ctempbh from ec_xueyuan where ctempbh<>'' group by ctempbh having(count(ctempbh))>1)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: