如何删除 MySQL 表上的重复项? [英] How to delete duplicates on a MySQL table?

查看:26
本文介绍了如何删除 MySQL 表上的重复项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 MySQL 表上DELETE 指定 sid 的重复行.

I need to DELETE duplicated rows for specified sid on a MySQL table.

如何使用 SQL 查询执行此操作?

How can I do this with an SQL query?

DELETE (DUPLICATED TITLES) FROM table WHERE SID = "1"

类似这样的事情,但我不知道该怎么做.

Something like this, but I don't know how to do it.

推荐答案

这会在原地删除重复项,而无需创建新表

this removes duplicates in place, without making a new table

ALTER IGNORE TABLE `table_name` ADD UNIQUE (title, SID)

注意:只有当索引适合内存时才有效

note: only works well if index fits in memory

这篇关于如何删除 MySQL 表上的重复项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆