一些实用的mysql语句(不断积累更新)
1.数据表里仅仅有生日字段,想计算出其年龄的mysql语句:
SELECT *,DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW( ))-TO_DAYS(生日字段)),'%Y')+0 AS age FROM 表名;
1.数据表里仅仅有生日字段,想计算出其年龄的mysql语句:
SELECT *,DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW( ))-TO_DAYS(生日字段)),'%Y')+0 AS age FROM 表名;