0

I tried to create this MySQL event. My code:

    delimiter |

CREATE EVENT `add_time`
    ON SCHEDULE
      EVERY 1 SECOND
    COMMENT 'Adding 1 second to online time'
    DO
      BEGIN
        UPDATE `users` SET `OnlineTime`=`OnlineTime`+1 WHERE 1;
      END |

delimiter ;

Now, this isn't working :/. I'm new Mysql user and I don't know how to loop, if(), get column data in variable ect. What I wanna do is:

Add OnlineTime to every user where OnlineTime is < 5000sec, if OnlineTime is >= 5000sec I want to delete that user.

1 Answers1

0

Instead, record the start time of the user. The EVENT would not increment a timer, instead it would subtract to see if the time limit has been exceeded.

Rick James
  • 135,179
  • 13
  • 127
  • 222