0

I'd like (if it possible) check a time and if time = special time, make update of the table.

My idea:

select current_time()
if current_time = 15:19 
{
   update tasks set finished = replace (finished, '1', '0')
}

Do you have any ideas???

1 Answer 1

2

Use an event for that

delimiter //
CREATE EVENT IF NOT EXISTS your_event
ON SCHEDULE EVERY 1 DAY 
STARTS  '2014-07-04 15:19:00'
ON COMPLETION PRESERVE ENABLE
DO
    update tasks 
    set finished = replace (finished, '1', '0');
//

It will be executed automatically every day on the defined time.

Sign up to request clarification or add additional context in comments.

3 Comments

Ok! Thanks, but I will add this part of code to website on the PHP. How bind for PHP?
$sql = mysqli_query($con, "CREATE EVENT IF NOT EXISTS your_event ON SCHEDULE EVERY 1 DAY STARTS '2014-07-04 15:19:00' ON COMPLETION PRESERVE ENABLE DO update tasks set finished = replace (finished, '1', '0')"); is it true?
Look - s1.radikali.ru/uploads/2014/7/4/… - Finished has 3 row - Did query - s1.radikali.ru/uploads/2014/7/4/… - and check a table - s1.radikali.ru/uploads/2014/7/4/… - Finished the same (((

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.