I have a db with multiple tables. The tables have all the same structure with one column called date and a bunch of other columns with various data.
I can remove the duplicates from a single table as follow:
DELETE FROM table1
WHERE EXISTS (
SELECT 1 FROM table1 p2
WHERE table1.date = p2.date
AND table1.ROWID > p2.ROWID
)
I have about 30 tables to clean regularly. Although I could run the above code for each table, is there a way to do this via a for loop after getting the list of tables in the db as:
SELECT name FROM sqlite_master WHERE type='table'