标签: mysql time difference
我的表created_at和updated_at中有2列,如果时间大于20秒,我想知道如何返回差异?
答案 0 :(得分:0)
如果列为datetime值,则使用timestampdiff函数应该有效:
datetime
timestampdiff
SELECT TIMESTAMPDIFF(SECOND,created_at,updated_at) AS diff_in_secs FROM table WHERE TIMESTAMPDIFF(SECOND,created_at,updated_at) > 20;
Example