MySQL和SQLite根据生日算年龄
MySQL:
1、select (date_format(from_days((to_days(now()) - to_days(birthday))),'%Y') + 0) AS age from table.
2、select timestampdiff(YEAR,birthday,curdate()) AS age from table
SQLite:
1、SELECT (strftime('%Y', 'now') - strftime('%Y', birthday)) - (strftime('%m-%d', 'now') < strftime('%m-%d', birthday)) from customer;
2、select cast(strftime('%Y.%m%d', 'now') - strftime('%Y.%m%d', birthday) as int) from customer;