mysql与create_at之间的时差和更新时间

时间:2015-07-31 17:11:46

标签: mysql time difference

我的表created_at和updated_at中有2列,如果时间大于20秒,我想知道如何返回差异?

1 个答案:

答案 0 :(得分:0)

如果列为datetime值,则使用timestampdiff函数应该有效:

SELECT TIMESTAMPDIFF(SECOND,created_at,updated_at) AS diff_in_secs 
FROM table
WHERE TIMESTAMPDIFF(SECOND,created_at,updated_at) > 20;

Example