SQL时间过去了

时间:2015-01-06 07:49:27

标签: mysql

我搜索了,我尝试了这些示例,但每个脚本都不正确!

这是我用于测试的脚本

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个结果!

1 个答案:

答案 0 :(得分:1)

应该是

  

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

对于COLUMN,无需 Single Quote '

同样在删除查询中,您是 deleting all the record matching datetime >= (NOW() + INTERVAL 1 DAY)

在选择查询中,您 retreiving records that matched datetime >= (NOW() + INTERVAL 1 DAY).

当你删除时,你将如何获得记录。的 You will always get ZERO RECORDS