Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.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_Time_Between - Fatal编程技术网

在mysql中选择特定时间段之间的所有记录

在mysql中选择特定时间段之间的所有记录,mysql,time,between,Mysql,Time,Between,例如,我有下表: id....name....fromtime....totime 1.....a.......00:00.......00:09:59 2.....a.......00:10.......00:19:59 3.....a.......00:20.......00:29:59 4.....a.......00:30.......00:39:59 5.....a.......00:40.......00:49:59 我想检索属于a(不是问题)且在00:05和00:

例如,我有下表:

id....name....fromtime....totime
1.....a.......00:00.......00:09:59
2.....a.......00:10.......00:19:59  
3.....a.......00:20.......00:29:59  
4.....a.......00:30.......00:39:59  
5.....a.......00:40.......00:49:59  
我想检索属于a(不是问题)且在00:05和00:25之间的所有记录,也就是说,对于上面的示例,是第1行到第3行,不包括第4行和第5行

如何使用mysql实现这一点?
谢谢

请考虑在新列中使用'between'子句,该列组合了
fromtime
totime

例如,
从您的\u表中选择id,fromtime totime作为“已用\u时间”,其中已用\u时间介于5和25之间
。或者类似的。根据列的类型,查询将有所不同

请参阅此处的更多信息:

和FromTime>=subtime($time),'00:10:00')-同时获取第一行

到目前为止,请发布您尝试过的任何查询。提示:要过滤日期和时间,应该使用不等式(
=
我在编写时尝试了“between”和简单运算符,但我要查找的“To”与我要查找的“from”不在同一行,因此我得到的结果集为空。