mysql删除重复数据
我有一张 resource 表,现在要删除其中 user_id 和 book_id 同时重复的数据,只保留一条。
DELETE FROM `resource`
WHERE `id` NOT IN (
SELECT MIN(`id`)
FROM `resource`
GROUP BY `user_id`, `book_id`
);
我有一张 resource 表,现在要删除其中 user_id 和 book_id 同时重复的数据,只保留一条。
DELETE FROM `resource`
WHERE `id` NOT IN (
SELECT MIN(`id`)
FROM `resource`
GROUP BY `user_id`, `book_id`
);