基于此,我如何设定整个00:00 - 23.59(昨天)的间隔
int
答案 0 :(得分:2)
试一试 -
SELECT SUM(quantity)
FROM downloads
WHERE
date>=CONCAT(SUBDATE(CURDATE(), INTERVAL 1 DAY),' 00:00:00')
AND date<= CONCAT(SUBDATE(CURDATE(), INTERVAL 1 DAY),' 23:59:59')
或者您可以使用 -
SELECT SUM(quantity)
FROM downloads
WHERE
date>=SUBDATE(CURDATE(), INTERVAL 1 DAY)
AND date< CURDATE();
答案 1 :(得分:0)
您可以尝试这样:
SELECT SUM(quantity)
FROM downloads
WHERE
date = DATE_sub(date,INTERVAL 1 DAY);
了解更多信息:https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-add