Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/68.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 - Fatal编程技术网

MYSQL查询时间戳忽略秒数

MYSQL查询时间戳忽略秒数,mysql,Mysql,我有一个MYSQL数据库,它在07:20:00开始更新,将在07:20:04结束 当我对此时完成的所有条目进行查询时,我并不真的想进行范围查询,而是在查询时 select * from Locations where timestamp = "2011-03-25 07:20:00" 我只得到下面的前3个条目 理想情况下,我需要的是一个忽略秒部分的查询,所以 select * from Locations where timestamp = "2011-03-25 07:20" 但这不会带来

我有一个MYSQL数据库,它在07:20:00开始更新,将在07:20:04结束

当我对此时完成的所有条目进行查询时,我并不真的想进行范围查询,而是在查询时

select * from Locations where timestamp = "2011-03-25 07:20:00"
我只得到下面的前3个条目

理想情况下,我需要的是一个忽略秒部分的查询,所以

select * from Locations where timestamp = "2011-03-25 07:20"
但这不会带来任何回报

1159    45.9432 5.0913  2011-03-25 07:20:00 256
1160    52.5254 10.6599 2011-03-25 07:20:00 1515
1161    49.967  7.2264  2011-03-25 07:20:00 1540
1162    54.1803 11.2977 2011-03-25 07:20:01 260
1163    55.1114 12.5347 2011-03-25 07:20:01 261
1164    43.4058 4.86937 2011-03-25 07:20:02 262
1165    42.3209 -0.57372    2011-03-25 07:20:02 263
1166    51.3763 3.23578 2011-03-25 07:20:02 265
1167    50.1532 6.40325 2011-03-25 07:20:02 266
1168    50.7152 4.55064 2011-03-25 07:20:02 267
1169    50.3813 7.92902 2011-03-25 07:20:02 268
1170    52.1096 5.78085 2011-03-25 07:20:02 269
1171    56.0632 -2.6779 2011-03-25 07:20:02 271
1172    48.6551 11.25   2011-03-25 07:20:02 1574
1173    52.4609 5.08926 2011-03-25 07:20:02 272
1174    51.0239 3.02428 2011-03-25 07:20:02 273
1175    48.4228 11.4413 2011-03-25 07:20:02 275

你为什么不想做一个靶场呢?为什么这么邪恶

select * from Locations 
where timestamp between "2011-03-25 07:20:00" and "2011-03-25 07:20:59"

你为什么不想做一个靶场呢?为什么这么邪恶

select * from Locations 
where timestamp between "2011-03-25 07:20:00" and "2011-03-25 07:20:59"

尝试先转换列,不使用第二个,如下所示:

select * from Locations where date_format(timestamp, '%Y-%m-%d %k:%i') = "2011-03-25 07:20"

尝试先转换列,不使用第二个,如下所示:

select * from Locations where date_format(timestamp, '%Y-%m-%d %k:%i') = "2011-03-25 07:20"

这和删除秒值一样有效吗?@李·阿姆斯特朗:我认为无论时间戳是否被索引,这都是最有效的方法。这和删除秒值一样有效吗?@李·阿姆斯特朗:我认为无论时间戳是否被索引,这都是最有效的方法。