Home > database > Ask god how to write a delete history of SQL statements
Ask god how to write a delete history of SQL statements
Time:10-16
I have a table table_user_login_history, save the user's login history, but I just want to save each user login record in recent one month, so set up a regular task, to do this every other month, but how to define inside to write SQL statements to delete the earlier records, only keep each user login record in recent one month, thank you.
CodePudding user response:
The DELETE FROM table_user_login_history WHERE CREATE_DATE & lt; DATE_SUB (CURDATE (), the INTERVAL 1 MONTH);
CodePudding user response:
Like the wrong, is keeping every user in recent 100 records,