elect  case left(idcard,2) 
when '11' then '北京市'
when '12' then '天津市'
when '13' then '河北省'
when '14' then '山西省'
when '15' then '内蒙古自治区'
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 '广西壮族自治区'
when '46' then '海南省'
when '50' then '重庆市'
when '51' then '四川省'
when '52' then '贵州省'
when '53' then '云南省'
when '54' then '西藏自治区'
when '61' then '陕西省'
when '62' then '甘肃省'
when '63' then '青海省'
when '64' then '宁夏回族自治区'
when '65' then '新疆维吾尔自治区'
when '71' then '台湾省'
when '81' then '香港特别行政区'
when '82' then '澳门特别行政区'
else '未知'     
end   as 省份 ,
 
year(curdate())-if(length(idcard)=18,substring(idcard,7,4),if(length(idcard)=15,concat('19',substring(idcard,7,2)),null)) as 年龄, 
 
case if(length(idcard)=18, cast(substring(idcard,17,1) as UNSIGNED)%2, if(length(idcard)=15,cast(substring(idcard,15,1) as UNSIGNED)%2,3)) 
when 1 then '男'
when 0 then '女'
else '未知'
end as 性别
 
FROM `user`

最新文章

  1. Xcode如何编译Debug版和Release版
  2. Install DBD::mysql for Perl in XAMPP in Mac , solving errors
  3. xml之phpdom操作
  4. 抽象工厂模式[wiki]
  5. ORACLE每组只保留一条记录
  6. (转)asp.net分页存储过程
  7. python手机号码运营商归属测试
  8. Qt中使用OpenCV库
  9. bootstrap中的下拉菜单
  10. WEBZIP为什么打不开网页
  11. Redis 基础(一)
  12. [译]Ocelot - Caching
  13. 清晰讲解SQL语句中的内连接,通用于Mysql和Oracle,全是干货哦
  14. 雷林鹏分享:jQuery EasyUI 数据网格 - 设置排序
  15. Python 字符串增删改查的使用
  16. laravel zh-CN
  17. iCheck .js各种各样的插件 fuck Javascript
  18. nginx用户认证配置( Basic HTTP authentication)及认证原理和实现
  19. NSNotification的使用(对观察者模式最通俗、易懂的讲解)
  20. You Arent Gonna Need It 理解

热门文章

  1. day 17 模块
  2. 【Java】 Java反射机制总结
  3. 集合类Hash Set,LinkedHashSet,TreeSet
  4. 数据库(一):suse下MySQL安装
  5. PHP的htmlspecialchars、strip_tags、addslashes
  6. 基于AliOS的车载小程序
  7. PAT Basic 1042 字符统计 (20 分)
  8. new、virtual、override
  9. 文件上传 MIME类型检测
  10. node模块管理