Last active
December 7, 2019 22:38
-
-
Save pereirawe/1fc54a94234d25945edb97be72725c38 to your computer and use it in GitHub Desktop.
Move rows from a table to another from a date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET @START = 10, @finish = 3; | |
INSERT INTO old_log | |
SELECT | |
* | |
FROM | |
log | |
WHERE | |
time >= DATE(NOW() - INTERVAL @start MONTH ) | |
AND | |
time <= DATE(NOW() - INTERVAL @finish MONTH ); | |
DELETE FROM | |
log | |
WHERE | |
time >= DATE(NOW() - INTERVAL @start MONTH ) | |
AND | |
time <= DATE(NOW() - INTERVAL @finish MONTH ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment