日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

MySQL 根据身份证号查询个人信息

發(fā)布時間:2024/8/1 87 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MySQL 根据身份证号查询个人信息 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

select ?
-- 身份證號的前兩位是省份
case left(zjhm,2)?
when '11' then '北京市'
when '12' then '天津市'
when '13' then '河北省'
when '14' then '山西省'
when '15' then '內(nèi)蒙古自治區(qū)'
when '21' then '遼寧省'
when '22' then '吉林省'
when '23' then '黑龍江省'
when '31' then '上海市'
when '32' then '江蘇省'
when '33' then '浙江省'
when '34' then '安徽省'
when '35' then '福建省'
when '36' then '江西省'
when '37' then '山東省'
when '41' then '河南省'
when '42' then '湖北省'
when '43' then '湖南省'
when '44' then '廣東省'
when '45' then '廣西壯族自治區(qū)'
when '46' then '海南省'
when '50' then '重慶市'
when '51' then '四川省'
when '52' then '貴州省'
when '53' then '云南省'
when '54' then '西藏自治區(qū)'
when '61' then '陜西省'
when '62' then '甘肅省'
when '63' then '青海省'
when '64' then '寧夏回族自治區(qū)'
when '65' then '新疆維吾爾自治區(qū)'
when '71' then '臺灣省'
when '81' then '香港特別行政區(qū)'
when '82' then '澳門特別行政區(qū)'
else '其他' ? ??
end ? as 省份 ,

-- 截取身份證號的前四位就得到地市,這里以山東省為例
case left(zjhm,4)?
when '3701' then '山東省濟(jì)南市'
when '3702' then '山東省青島市'
when '3703' then '山東省淄博市'
when '3704' then '山東省棗莊市'
when '3705' then '山東省東營市'
when '3706' then '山東省煙臺市'
when '3707' then '山東省濰坊市'
when '3708' then '山東省濟(jì)寧市'
when '3709' then '山東省泰安市'
when '3710' then '山東省威海市'
when '3711' then '山東省日照市'
when '3712' then '山東省萊蕪市'
when '3713' then '山東省臨沂市'
when '3714' then '山東省德州市'
when '3715' then '山東省聊城市'
when '3716' then '山東省濱州市'
when '3717' then '山東省菏澤市'
else '其他' ? ??
end as 地市,


-- 截取身份證號的前六位就得到區(qū)縣,這里以山東省濟(jì)南市為例(行政區(qū)劃可能會調(diào)整,以實(shí)際為準(zhǔn))
case left(zjhm,6)?
when '370102' then '山東省濟(jì)南市歷下區(qū)'
when '370103' then '山東省濟(jì)南市市中區(qū)'
when '370104' then '山東省濟(jì)南市槐蔭區(qū)'
when '370105' then '山東省濟(jì)南市天橋區(qū)'
when '370112' then '山東省濟(jì)南市歷城區(qū)'
when '370113' then '山東省濟(jì)南市長清區(qū)'
when '370114' then '山東省濟(jì)南市章丘區(qū)'
when '370115' then '山東省濟(jì)南市濟(jì)陽區(qū)'
when '370116' then '山東省濟(jì)南市萊蕪區(qū)'
when '370117' then '山東省濟(jì)南市鋼城區(qū)'
when '370124' then '山東省濟(jì)南市平陰縣'
when '370126' then '山東省濟(jì)南市商河縣'
else '其他' ? ??
end as 區(qū)縣,

-- 出生日期
IF (LENGTH(zjhm) = 18,CAST(SUBSTRING(zjhm, 7, 8) AS date),
?? ?CAST(CONCAT('19',SUBSTRING(zjhm, 7, 6)) AS date) ) AS 出生日期,


-- 年齡
year(curdate())-if(length(zjhm)=18,substring(zjhm,7,4),if(length(zjhm)=15,concat('19',substring(zjhm,7,2)),null)) as 年齡,?
?
-- 性別
case if(length(zjhm)=18, cast(substring(zjhm,17,1) as UNSIGNED)%2, if(length(zjhm)=15,cast(substring(zjhm,15,1) as UNSIGNED)%2,3))?
when 1 then '男'
when 0 then '女'
else '未知'
end as 性別
?
FROM `cs_id_card`

總結(jié)

以上是生活随笔為你收集整理的MySQL 根据身份证号查询个人信息的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。