mysql查询性别是否跟身份证一致

2022/1/24 19:10:05

本文主要是介绍mysql查询性别是否跟身份证一致,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

select * from (select
name,
gender % 2 gender,
agentcode,
certno,
SUBSTR( certno, LENGTH( certno )- 1, 1 ) sexNum,
SUBSTR( certno, LENGTH( certno )- 1, 1 )% 2 sexType,
(case ((gender % 2)=SUBSTR( certno, LENGTH( certno )- 1, 1 )% 2) when true then '1' else '0' end) result
FROM
t_agent ) a where a.result = '0'

 

说明:身份证倒数第二位为奇数:男;偶数:女



这篇关于mysql查询性别是否跟身份证一致的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程