Now there are two more tables, tcm and doc;
Db_count:
Id count
1 220
2 300
3 220
4 222
5 240
Db_date:
Id t_date count
1 2012-09-10 17:04:07 220
2 2012-09-11 15:04:07 224
3 2012-08-20 11:04:07 225
4 2012-02-11 17:04:07 300
5 10:04:07 500
6 2012-09-12 17:04:07 300
--- The Stored Procedure changes the count value of the db_count table to 0;
DELIMITER //
Create procedure update_count ()
BEGIN
DECLARE m date;
DECLARE y CURSOR for select t_date from db_date;
Declare continue handler for sqlstate '000000' SET k = 1;
OPEN y;
FETCH y INTO m;
If sysdate ()> m THEN
UPDATE db_date t, db_count g SET g. count = 0 WHERE t. id = g. id;
End if;
CLOSE y;
END //
DELIMITER;
---- The event is executed at an interval of 1 second.
DELIMITER //
Create event my_count
On schedule every 1 second do
Begin
Call update_count ();
End //
DELIMITER;
Select * from db_count;