What is wrong with my DELETE in SQL query?
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";
精彩评论