使用 phpmyadmin 管理重复项
我正在寻找一种工具,可以让我轻松管理 MySQL 数据库中的重复条目。
从某种意义上说,我不想使我的列“唯一”,但我想查看列中恰好具有完全相同值的记录。
如果我可以制作这样一个使用常用界面仅显示此类记录的 SQL 查询,那就太好了。
I'm looking for a tool that allows me to easily manage duplicate entries in the MySQL database.
In a sense, I don't want to make my columns 'UNIQUE', but I want to review the records that happen to have exactly the same value in a column.
It would be nice if I could craft such an SQL query that shows only such records using the usual interface.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
要获取重复项,只需在表上使用自连接:
t1.id < t2.id 将确保每个重复项仅出现一次。
To get duplicates, just use a self-join on the table :
The t1.id < t2.id will make sure every duplicate will only appear once.
应该可以通过查询来选择它们:
Should be possible to select them with a query:
我不确定界面,但这个工具肯定可以实现前者: http://www.dodownload.com/business+manage/access+database/mysql+delete+remove+duplicate+entries+software.html
I'm not sure about the interface, but this tool certainly does the former: http://www.dodownload.com/business+manage/access+database/mysql+delete+remove+duplicate+entries+software.html
在上面的wimvds答案中; phpMyAdmin 显示以下警告:
当前选择不包含唯一列。网格编辑、复选框、编辑、复制和删除功能不可用。
要启用编辑/复制/删除,第一行可以更改为:
或
因此您可能需要使用 wimvds 的查询来查看重复项(可能与其他字段一起),然后使用第二个查询来编辑或删除重复记录。
(也许还有一种方法可以列出重复项;在相邻行中并且可编辑?)
In wimvds answer above; phpMyAdmin shows the following warning:
Current selection does not contain a unique column. Grid edit, checkbox, Edit, Copy and Delete features are not available.
To enable edit/copy/delete, the first line can be changed to either:
or
Hence you may want to use wimvds's query to review duplicates (maybe along with other fields), then the second query to edit or delete duplicate records.
(Perhaps there is also a way to list duplicates; in adjacent rows, and editable?)