如何使用时间戳计算元素

时间:2012-08-18 23:00:21

标签: php mysql timestamp counter

我的表中有一个时间戳值,它设置为更新当前时间戳。

当用户进行x工作时,它会自动更新。

我想计算在过去30分钟内x有多少用户工作。我需要什么mysql查询?

1 个答案:

答案 0 :(得分:2)

您应该使用查询的count聚合函数

select 
    count(timestampColumnName) 
from 
    yourtable 
where 
    timestampColumnName>date_sub(now(), interval 30 minute)
    // and any other conditions as needed
相关问题