The fact is that I need to delete if there are more than 20 records and at the same time only old ones, that is, by date. I found a SQL query somewhere
DELETE tt FROM ( SELECT DISTINCT uid --- these 3 lines can be replaced FROM tableX --- with: UserTable AS du ) AS du --- a table that you probably have JOIN tableX AS tt ON tt.uid = du.uid AND tt.timestampColumn > ( SELECT timestampColumn AS ts FROM tableX WHERE uid = du.uid ORDER BY ts ASC LIMIT 1 OFFSET 199 ) but it is completely incomprehensible. I can delete if more than 20, but the problem is that there are 2 checks, and I'm new to SQLite, a mess in my head.
I have the following columns:
private static final String TABLE_SEARCH = "search_table"; private static final String KEY_ID = "id"; private static final String KEY_DATE = "date"; As in my case, use the query above. And how to remake db.delete ()?