mysql 怎么用SQL语句将老身份证号15位补位到新身份证号18位
2、执行sql语句,身份证号补位(老身份证号15位补位到新身份证号18位)
UPDATE person_catalog_info_s SET ID_CARD = CONCAT
(
SUBSTRING(ID_CARD,1,6),'19',SUBSTRING(ID_CARD,7,9),SUBSTRING('10X98765432',
(CAST(SUBSTRING(ID_CARD,1,1)AS SIGNED)*7+
CAST(SUBSTRING(ID_CARD,2,1)AS SIGNED)*9+
CAST(SUBSTRING(ID_CARD,3,1)AS SIGNED)*10+
CAST(SUBSTRING(ID_CARD,4,1)AS SIGNED)*5+
CAST(SUBSTRING(ID_CARD,5,1)AS SIGNED)*8+
CAST(SUBSTRING(ID_CARD,6,1)AS SIGNED)*4+
1*2+
9*1+
CAST(SUBSTRING(ID_CARD,7,1)AS SIGNED)*6+
CAST(SUBSTRING(ID_CARD,8,1)AS SIGNED)*3+
CAST(SUBSTRING(ID_CARD,9,1)AS SIGNED)*7+
CAST(SUBSTRING(ID_CARD,10,1)AS SIGNED)*9+
CAST(SUBSTRING(ID_CARD,11,1)AS SIGNED)*10+
CAST(SUBSTRING(ID_CARD,12,1)AS SIGNED)*5+
CAST(SUBSTRING(ID_CARD,13,1)AS SIGNED)*8+
CAST(SUBSTRING(ID_CARD,14,1)AS SIGNED)*4+
CAST(SUBSTRING(ID_CARD,15,1)AS SIGNED)*2)%11+1,1))
WHERE LENGTH(ID_CARD)=15;
3、执行后结果。
希望能帮助到大家,小编以后会一直坚持更新内容,工作中遇到的问题和心得都会在这里分享,也是我的笔记,欢迎大家点赞、收藏、关注、分享。如果大佬们资金充裕,也可以稍微的打赏一下,感谢你的支持。