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



--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)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值