Answer the question
In order to leave comments, you need to log in
What is the correct way to commit the last value (at the end of the day) to the DB?
A script hangs on the crown that runs every 30 seconds. The script simply changes the values in the database, I need to fix the latest value at the end of the day (write it in a column specially selected for this). What is the best way to do this?
The very first thing that comes to mind is to add a condition in the script:
если время >23.58 И время меньше <00.00,
то запускаем функцию
But for some reason I don't like this approach. Is it possible to do it somehow differently (perhaps with trigger functions in mysql)?
Answer the question
In order to leave comments, you need to log in
it may be easier to always write to the second special table, but overwrite today's value
INSERT INTO table_name (`column1`, `column2`, `column3`, `date`)
VALUES ('value1', 'value2', 'value3', CURDATE())
ON DUPLICATE KEY UPDATE
`column1`=VALUES(`column1`),
`column2`=VALUES(`column2`),
`column3`=VALUES(`column3`);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question