= (NOW() -6ren">
gpt4 book ai didi

mysql - SQL 时间已过去

转载 作者:行者123 更新时间:2023-11-29 12:29:25 25 4
gpt4 key购买 nike

我进行了搜索,并尝试了示例,但每个脚本都不正确!

这是我仅用于测试的脚本

mysql_query("Delete FROM ScannedIDs WHERE 'datetime' >= (NOW() + INTERVAL 1 DAY)") or 
die(mysql_error());

$sql = mysql_query("Select * FROM ScannedIDs WHERE 'datetime' >= (NOW() + INTERVAL 1 DAY)") or
die(mysql_error());

$rows = mysql_num_rows($sql);
echo "Found $rows results!";
<小时/>

这是MYSQL数据

                                        steamid             datetime
Edit Edit Copy Copy Delete Delete 76561198035301803 2015-01-06 01:40:06
Edit Edit Copy Copy Delete Delete 76561197984607788 2015-01-06 01:40:06
Edit Edit Copy Copy Delete Delete 76561197965902616 2015-01-06 01:40:06
Edit Edit Copy Copy Delete Delete 76561198043885314 2015-01-06 01:40:06
Edit Edit Copy Copy Delete Delete 76561198040227469 2015-01-06 01:40:06
Edit Edit Copy Copy Delete Delete 76561198054594853 2015-01-06 01:40:06
Edit Edit Copy Copy Delete Delete 76561198008404239 2015-01-06 01:40:06
Edit Edit Copy Copy Delete Delete 76561198021278627 2015-01-06 01:40:06
<小时/>

此时,它是相同的确切日期,它应该返回 0 个结果!从现在起 24 小时后,预计会返回 8 个结果。

我不明白为什么一天还没有过去,它就返回 8 个结果!

最佳答案

应该是

WHERE datetime >= (NOW() + INTERVAL 1 DAY)

COLUMN 不需要单引号 '

此外,在删除查询中,您删除与日期时间 >= (NOW() + INTERVAL 1 DAY) 匹配的所有记录

在选择查询中,您检索与日期时间 >= (NOW() + INTERVAL 1 DAY) 匹配的记录。

当您已经删除时,您将如何获得记录。 您将始终获得零记录

关于mysql - SQL 时间已过去,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27794270/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com