SELECT
p.idcard,
p.`gender`,
IF (LENGTH(p.idcard) = 18,
CAST(SUBSTRING(p.idcard, 7, 8) AS DATETIME),
CAST(CONCAT('19',SUBSTRING(p.idcard, 7, 6)) AS DATETIME)) AS Birthday,
IF (SUBSTR(p.idcard, LENGTH(p.idcard) - 1,1) % 2 = 1, '男', '女') AS sex
FROM `a_community_people_5520` p
WHERE
p.idcard REGEXP '[1-8][0-8][0-9]{16}|[1-8][0-8][0-9]{15}X|[1-8][0-8][0-9]{13}'
AND (
LENGTH(p.idcard) = 18
OR LENGTH(p.idcard) = 15
)
LIMIT 1000000
网友评论