用sql实现18位身份证校验代码分享 身份证校验位计算
时间:2024-01-13 13:37:11
身份证校验码的计算方法
1、将前面的身份证号码17位数分别乘以不同的系数。第i位对应的数为[2^(18-i)]mod11。从第一位到第十七位的系数分别为:7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2 ;
2、将这17位数字和系数相乘的结果相加;
3、用加出来和除以11,看余数是多少?;
4、余数只可能有0 1 2 3 4 5 6 7 8 9 10这11个数字。其分别对应的最后一位身份证的号码为1 0 X 9 8 7 6 5 4 3 2;
with t as(select '34052419800101001X'id from dual)
select id
from t
where exists(select 1
from dual connect by level<=length(id)-1 --17
having mod(sum(substr(id,level,1)*power(2,18-level)),11)=
case substr(id,-1,1)
when '1' then 0
when '0' then 1
when 'X' then 2
else
12-substr(id,-1,1)
end);
标签:sql,身份证
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python和shell获取文本内容的方法
2023-06-20 05:42:35
30行Python代码打造一款简单的人工语音对话
2023-03-16 18:10:19
![](https://img.aspxhome.com/file/2023/2/131442_0s.png)
水晶报表 分页 的问题
2022-11-08 05:53:30
Keepalived+HAProxy实现MySQL高可用负载均衡的配置
2024-01-18 23:08:52
![](https://img.aspxhome.com/file/2023/7/109817_0s.jpg)
说说CSS Hack 和向后兼容
2010-05-17 13:11:00
![](https://img.aspxhome.com/file/UploadPic/20105/17/css-hack-and-standard-31s.png)
python DataFrame中stack()方法、unstack()方法和pivot()方法浅析
2023-12-13 17:38:55
![](https://img.aspxhome.com/file/2023/3/124223_0s.png)
js 客户端打印html 并且去掉页眉、页脚的实例
2024-04-22 22:24:26
Django如何防止定时任务并发浅析
2021-10-23 01:09:54
vue-cli开发环境实现跨域请求的方法
2024-05-13 09:14:10
MySQL中CURRENT_TIMESTAMP的使用方式
2024-01-12 20:10:29
![](https://img.aspxhome.com/file/2023/6/78206_0s.png)
Sql server中时间查询的一个比较快的语句
2008-12-29 14:16:00
PHP析构函数destruct与垃圾回收机制的讲解
2023-07-11 21:05:36
javascript new fun的执行过程
2010-08-05 21:23:00
![](https://img.aspxhome.com/file/UploadPic/20108/5/20100805150736846-93s.jpg)
获取星期几的名称
2012-01-29 18:16:31
Python实现敲击木鱼积累功德小项目
2021-02-11 05:29:03
JavaScript实现复制内容到粘贴板代码
2024-04-25 13:14:01
安全地关闭MySQL服务的教程
2024-01-16 23:50:13
解决python replace函数替换无效问题
2022-05-20 18:51:57
python数据可视化之条形图画法
2021-08-07 13:43:22
![](https://img.aspxhome.com/file/2023/6/98966_0s.jpg)
Python selenium文件上传下载功能代码实例
2021-04-24 07:21:28
![](https://img.aspxhome.com/file/2023/9/109419_0s.png)