ID of the Message, CreateTime, status, isNew
Data structure, such as:
1, "we don't like" 2018, '2018-10-12', 1, 1;
2, "2018 we don't like 2", '2018-10-15', 2, 2;
3, "we don't like 3" 2018, '2018-11-12', 1, 1;
4, "we don't like 4" 2018, '2018-12-15', 2, 1;
5, "2018 we don't like 5, '2018-12-10', 1, 1;
6, "we don't like 6" 2018, '2018-11-11', 2, 2;
Results:
1. The need of data query and delete 1 months ago;
2. IsNew, 1 is the latest data, 2 for the old data, new data query, only need to delete the old data.
CodePudding user response:
delete from TB where add_months (sysdate, 1) & gt; Createtime;
delete from TB where isnew=2;