Counting rows where a timestamp is less than 24 hours old(计算时间戳小于 24 小时的行数)
问题描述
对于下面的查询,我如何计算 datesent
小于 24 小时的行数?(字段 datesent
是一个时间戳).
For the query below, how could I count the number of rows where datesent
is less than 24 hours old? (The field datesent
is a timestamp).
提前致谢,
约翰
$message = "SELECT datesent, recipient
FROM privatemessage
WHERE recipient = '$u'";
$messager = mysql_query($message);
$messagearray = array();
推荐答案
使用:
SELECT COUNT(*) AS cnt
FROM PRIVATEMESSAGE pm
WHERE pm.datesent >= DATE_SUB(NOW(), INTERVAL 1 DAY)
这篇关于计算时间戳小于 24 小时的行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!