在 SQlite3 中删除重复的记录
在使用 SELECT
语句查询时可以添加 DISTINCT
选项,来将重复的记录移除。
`SELECT DISTINCT column_list FROM table;
对多列使用 DISTINCT
SELECT DISTINCT city, country FROM customers ORDER BY country;
SELECT DataId, COUNT(*) c FROM DataTab GROUP BY DataId HAVING c > 1;
在删除记录之前,做好备份!!
DELETE FROM Follows WHERE rowid NOT IN (SELECT min(rowid) FROM Follows GROUP BY userId);
DELETE FROM sms WHERE rowid NOT IN (SELECT min(rowid) FROM sms GROUP BY address, body);
要删除
DELETE FROM sms WHERE rowid NOT IN (SELECT min(rowid) FROM sms GROUP BY address, body);