最近处理的系统中出现了大量重复数据,身份证号和姓名一样。而身份证号是作为用户登录系统的用户名,这样如果用户修改了密码,就有可能出现登录不了的情况。
1 delete from where not in
2 ( select max from group by
2 ( select max from group by
备份其它的语句:
根据身份证号码更新用户的的性别信息:
update users set gender='男' where length(idcard)=18 and substr(idcard, 17, 1) in ('1','3','5','7','9')
update users set gender='Ů' where length(idcard)=18 and substr(idcard, 17, 1) in ('0','2','4','6','8')
update users set gender='男' where length(idcard)=15 and substr(idcard, 15, 1) in ('1','3','5','7','9')
update users set gender='Ů' where length(idcard)=15 and substr(idcard, 15, 1) in ('0','2','4','6','8')
select t.idcard, t.gender from users t
更新人员的身份证号码信息:
update set = substr(cardid, 0 , 17 ) || ' X ' where like ' %x ' and = ' 居民身份证 ' and = 18
使用A表的数据更新B表的对应数据:
update set = select as
from where =
where exists ( select 1 from where = t_e1.eneeid)
from where =
where exists ( select 1 from where = t_e1.eneeid)