V
V
Viplayer2018-12-29 11:08:11
SQL
Viplayer, 2018-12-29 11:08:11

How to delete a record in sql by time specified by the user?

I have a database in phpMyAdmin with a table for displaying records (user orders), which has its own filling form for the user so that outdated records do not "roll around" I want to add a new field in the date_discharge filling form of the timestamp type, where the user can set the time, for example, when he this will no longer be necessary (for example, in a week on 01/07/2019), so I want to make it automatically deleted in the database when the date value of a certain record occurs, how can I implement this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Boris Syomov, 2018-12-29
@Viplayer

You need to write a script that will delete records older than a week, and run it by cron once a day (or more often to delete in parts). The language is not important. The script will be very simple, literally connecting to the database and one request.

R
Ruslan Dorofeev, 2018-12-29
@rusld

I heard that in mysql you can create events
First enable Then the entered time is used in the event creation request and, accordingly, the DELETE FROM command ...
I didn't do it myself, but you can try

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question