selecting rows in the last 5 minutes using unix time stamp

后端 未结 2 1388
我寻月下人不归
我寻月下人不归 2020-12-17 03:49

Iam trying to figure out whetere data was save to the db in the las 5 minutes.

SELECT COUNT(id), DATE_FORMAT(`timestamp`, \'%Y-%m-%d %H:%i\')
FROM `table`
WH         


        
2条回答
  •  南笙
    南笙 (楼主)
    2020-12-17 04:35

    You could do like that :

    SELECT COUNT(id), DATE_FORMAT(`timestamp`, '%Y-%m-%d %H:%i')
    FROM `table`
    WHERE `timestamp` BETWEEN (DATE_SUB(NOW(),INTERVAL 5 MINUTE)) AND NOW()
    

提交回复
热议问题