php - How to regularly import data from a mysql data table to another table in the same database
PHP中文网
PHP中文网 2017-05-16 13:04:21
0
2
352

Want to import all today's sign-in data table signInfo into another table yesterdaySignInfo in the same database at 23:59 every day? Can it be done using only sql statements?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
Ty80

Can be solved using mysql events

//Open event scheduler

set global event_scheduler = on  

//Create event

delimiter $$
create event if not exists yesterday_sign_log
on schedule every 1 day
starts timestamp '2017-05-03 23:50'
on completion preserve enable
do begin
drop table if exists yesterdaySignInfo;
create table yesterdaySignInfo like signInfo;
insert into yesterdaySignInfo select * from signInfo;
end $$
delimiter;
Ty80

SQL can be written like this

drop table if exists yesterdaySignInfo;
create table yesterdaySignInfo like signInfo;
insert into yesterdaySignInfo select * from signInfo;
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template