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 - Fatal编程技术网

从mysql数据库中获取特定时间段内的所有记录

从mysql数据库中获取特定时间段内的所有记录,mysql,Mysql,我编写了一个代码来获取5分钟内的所有记录(获取所有注释),我在数据库中的日期是UNIX时间戳。它似乎不起作用。问题是 select comment_id,from_unixtime(a.date / 1000, '%Y-%m-%d %H:%i') from ai_shipment_comments a, ai_users b where a.parent_id = '26' or a.comment_id='26' and a.user_id=b.user_id AND a.date >=

我编写了一个代码来获取5分钟内的所有记录(获取所有注释),我在数据库中的日期是UNIX时间戳。它似乎不起作用。问题是

select comment_id,from_unixtime(a.date / 1000, '%Y-%m-%d %H:%i') from ai_shipment_comments a, ai_users b where a.parent_id = '26' or a.comment_id='26' and a.user_id=b.user_id AND a.date >= unix_timestamp(CURRENT_TIMESTAMP - INTERVAL 1 MINUTE) * 1000 ORDER BY a.date ASC

结果为空,但应返回结果

您是否检查了计算是否给出了合理的时间值?是的,我检查了。但是仍然没有结果为什么你要乘以*1000?你已经有了一个时间戳。如果没有时间戳,它也不会显示正确的结果