开发者

What is wrong with my DELETE in SQL query?

开发者 https://www.devze.com 2023-02-28 10:32 出处:网络
My SQL query contai开发者_运维知识库ns an equation that doesn\'t function. Here is what it looks like:

My SQL query contai开发者_运维知识库ns an equation that doesn't function. Here is what it looks like:

$delete = ("DELETE FROM table WHERE $timecode - time < 86400");

Basically I want to delete the rows that are recorded a day ago (aka 86400s). As you can guess, $timecode = time(); and the time column is also a time stamp.


Best guess is that the time column in your table is confused with the time function. Second problem: from your description, don’t you want > instead of <?

DELETE FROM t WHERE $timecode - t.time > 86400;


Does this work for you?

$delete = "DELETE FROM table WHERE (NOW()-86400) > time";

0

精彩评论

暂无评论...
验证码 换一张
取 消