使用 phpmyadmin 管理重复项

发布于 2024-09-14 06:11:51 字数 139 浏览 1 评论 0原文

我正在寻找一种工具,可以让我轻松管理 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

难以启齿的温柔 2024-09-21 06:11:51

要获取重复项,只需在表上使用自连接:

select t1.id, t2.id, t1.value
from table t1
inner join table t2 on t1.value=t2.value
where t1.id < t2.id

t1.id < t2.id 将确保每个重复项仅出现一次。

To get duplicates, just use a self-join on the table :

select t1.id, t2.id, t1.value
from table t1
inner join table t2 on t1.value=t2.value
where t1.id < t2.id

The t1.id < t2.id will make sure every duplicate will only appear once.

深巷少女 2024-09-21 06:11:51

应该可以通过查询来选择它们:

select myColumn, count(myColumn) as myCount from myTable group by myColumn having myCount > 1 order by myCount; 

Should be possible to select them with a query:

select myColumn, count(myColumn) as myCount from myTable group by myColumn having myCount > 1 order by myCount; 
望笑 2024-09-21 06:11:51

在上面的wimvds答案中; phpMyAdmin 显示以下警告:

当前选择不包含唯一列。网格编辑、复选框、编辑、复制和删除功能不可用。

要启用编辑/复制/删除,第一行可以更改为:

select t1.id, t1.value 

select t2.id, t2.value

因此您可能需要使用 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:

select t1.id, t1.value 

or

select t2.id, t2.value

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?)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文