在Mysql中将时间戳转换为age

时间:2016-10-15 22:26:31

标签: mysql sql

我有这个问题:

SELECT * FROM `people` WHERE `age` > '19' ORDER BY `id` DESC LIMIT 10


| id | name | age       |
-------------------------
| 1  | a    | 842479200 |
-------------------------
| 2  | b    | 748562400 |
-------------------------

age行包含时间戳。 如何将它转换为年龄,如15,14,20,25?

1 个答案:

答案 0 :(得分:0)

您需要使用以下内容转换为正确的格式:

SELECT people, name, strftime("%Y-%d-%m", age, 'unixepoch') AS age 
FROM `people` WHERE `age` > '19' ORDER BY `id` DESC LIMIT 10