php 查询当天的某一时刻范围内的数据怎么写?

WBOY
Libérer: 2016-06-23 13:37:50
original
1243 Les gens l'ont consulté

php连接mysql数据库要查询每天的某一时刻(或某几个时刻)范围内的数据,例如要查询当天17:25-17:35之间是否在数据库中接收到数据,应该怎么写?


回复讨论(解决方案)

select ... where 时间 between 起始 and 结束

select * from table where addtime>=' ?始??' and addtime

我只查当天的数据,楼上的写法把数据库这段时刻的所有数据都查到了。

select ... where 时间 between 起始 and 结束


“时间”当天的数据怎么写?
“起始与结束”的时间只有时分秒怎么写?
我要查询每天这个时间点范围内的数据,而不是特定某一天的数据。

select * from table where addtime>=' ?始??' and addtime
我只查当天的数据,当天的数据怎么写?
“起始与结束”的时间只有时分秒怎么写?
我要查询每天这个时间点范围内的数据,而不是特定某一天的数据。

DATE_FORMAT()成你要的时间格式,再去查询。不过效率会低


select * from table where addtime>=' ?始??' and addtime
我只查当天的数据,当天的数据怎么写?
“起始与结束”的时间只有时分秒怎么写?
我要查询每天这个时间点范围内的数据,而不是特定某一天的数据。



$starttime = '17:25:00';
$endtime = '17:35:00';

$sql="select * from table where addtime>='".date('Y-m-d').' '.$starttime."' and addtime

原来楼主的日期和时间是分两个字段存放地,那你得用日期+时间组成一个新值,用日期+时间>='?始日期??'  and 日期+时间



select * from table where addtime>=' ?始??' and addtime
我只查当天的数据,当天的数据怎么写?
“起始与结束”的时间只有时分秒怎么写?
我要查询每天这个时间点范围内的数据,而不是特定某一天的数据。



$starttime = '17:25:00';
$endtime = '17:35:00';

$sql="select * from table where addtime>='".date('Y-m-d').' '.$starttime."' and addtime
非常感谢版主,已经OK了,请问这方面的知识应该从哪些书,或者百度什么才能找到,我刚开始学,我找的书和视频只讲基本的查询,插入,删除操作,进一步详细的都没有。

#3 我只查当天的数据,楼上的写法把数据库这段时刻的所有数据都查到了。
#4 我要查询每天这个时间点范围内的数据,而不是特定某一天的数据。

那么你究竟要查什么呢?




select * from table where addtime>=' ?始??' and addtime
我只查当天的数据,当天的数据怎么写?
“起始与结束”的时间只有时分秒怎么写?
我要查询每天这个时间点范围内的数据,而不是特定某一天的数据。



$starttime = '17:25:00';
$endtime = '17:35:00';

$sql="select * from table where addtime>='".date('Y-m-d').' '.$starttime."' and addtime
非常感谢版主,已经OK了,请问这方面的知识应该从哪些书,或者百度什么才能找到,我刚开始学,我找的书和视频只讲基本的查询,插入,删除操作,进一步详细的都没有。

看看一些?源系?的源?。
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!