Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 实时查询数据库_Mysql_Sql - Fatal编程技术网

Mysql 实时查询数据库

Mysql 实时查询数据库,mysql,sql,Mysql,Sql,我正在从具有特定日期和时间的数据库中检索一些数据。假设我想实时查看数据 有没有一种方法可以自动提取数据而不指定确切的数据和时间 我的问题是: select store, Count(bananas) from database_name where Date_hour between '2017-04-06 07:00:00' and '2017-04-07 07:00:02' Group by sore 选择最近一小时的数据: SELE

我正在从具有特定日期和时间的数据库中检索一些数据。假设我想实时查看数据

有没有一种方法可以自动提取数据而不指定确切的数据和时间

我的问题是:

select   
    store,
    Count(bananas)
from
    database_name 
where   
    Date_hour between '2017-04-06 07:00:00' and '2017-04-07 07:00:02'
Group by 
    sore

选择最近一小时的数据:

SELECT   store,
         Count(bananas)
FROM     table_name 
WHERE    date_hour > DATE_SUB(NOW(), INTERVAL 1 HOUR)
GROUP BY store

如果你不给数据库诸如日期和时间之类的参数,数据库怎么知道该怎么做?你所说的“实时”是什么意思?你只是在寻找——关于如何使用它,请参阅Y.B.的答案。