18位身份证号码
select cast(substring(idno,7,8) as date) as 出生日期,2022-substring(idno,7,4) as age from tables where LENGTH(idno)=18
15位身份证号码
select cast(concat('19', substring(idno,7,6)) as date) as 出生日期, 2022-concat('19', substring(idno,7,2)) from tables where LENGTH(idno)=15
获取性别
// mod(id,2)=1 是指 id 是奇数
// mod(id,2)=0 是指 id是偶数
// 获取性别等于男的数据
select * from tables where length(idno)=18 mod(substring(idno, 17, 1), 2)=1
// 获取性别等于女的数据
select * from tables where length(idno)=18 mod(substring(idno, 17, 1), 2)=0