i'm doing my first DB on mySQL and I want to make an underground like system. To start the system I want to make them go from one station to another on a fixed time of 2 seconds so I use the following code
delimiter |
CREATE EVENT runBlue
ON SCHEDULE EVERY 2 SECOND
DO
BEGIN
WHILE (SELECT Actual_Station FROM route WHERE Actual_Station) < 311 DO
UPDATE mydb.route SET Actual_Station = (Actual_Station+1);
END WHILE;
WHILE (SELECT Actual_Station FROM route WHERE Actual_Station) >= 300 DO
UPDATE mydb.route SET Actual_Station = (Actual_Station-1);
END WHILE;
END |
delimiter ;
What concerns me is that there is no increment to the Actual_Station that is represented by an INT, the reason why I am doing this is because the underground is divided in 3 routes, this is the example for the first one that goes form station 300 to station 311.