mysql中通过身份证计算年龄
SELECT * FROM ( SELECT DATE_FORMAT(substring(t.id_card, 7, 8),"%Y-%m-%d") birthday, YEAR (now()) - YEAR (substring(t.id_card, 7, 8)) age FROM teacher t ) temp
substring()函数用来截取出生年月日
year(now())- year(substring(borrower_idcard,7,8)) age, 用来计算年龄