Hello! At the beginning of the PHP script, I had a need to delete rows from the Mysql database table that have been written to the database for more than 24 hours. Maybe someone faced such a task, or is there some function in Mysql for this? Please tell me, thanks in advance.
Answer 1, authority 100%
Um… I don’t know exactly, but I don’t think MySQL itself remembers the timestamp.
Therefore, add the recording time field and delete everything where the difference between the current and recorded times is more than 24 hours – such a request can be made without much difficulty.
DELETE FROM nya WHERE (timestamp < DATE_SUB(NOW(),INTERVAL 1 DAY))
You can, of course, write it differently, but the meaning will be approximately the same.