如何指定子句在Mysql中每5分钟一次

时间:2016-04-13 08:56:20

标签: mysql

在Mysql请求中,我想指定每5分钟选择一次值

 $sql = 'SELECT * FROM table WHERE datetime BETWEEN "2016-01-04 00:00:00" 
 $sql .= 'AND "2016-01-04 12:00:00" + "(and INTERVAL 5 minutes)"';

有人有想法吗?

1 个答案:

答案 0 :(得分:1)

你可以试试这个:

SELECT * FROM table
WHERE datetime BETWEEN '2016-01-04 00:00:00' AND '2016-01-04 12:00:00'
GROUP BY 
UNIX_TIMESTAMP(datetime) DIV 300