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中文网2017-05-16 13:06:21
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;
PHP中文网2017-05-16 13:06:21
SQL can be written like this
drop table if exists yesterdaySignInfo;
create table yesterdaySignInfo like signInfo;
insert into yesterdaySignInfo select * from signInfo;