mysql从数据库中仅选择重复记录 [英] mysql select ONLY duplicate records from database

查看:91
本文介绍了mysql从数据库中仅选择重复记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对mysql数据库中的重复记录执行某些操作.但是,我不想删除记录,并且只有两列是重复的.我如何才能找到这些记录?

I'm trying to do something with the duplicate records in a mysql database. however, I don't want to delete the records, and only two columns are duplicate. How can I find just these records?

推荐答案

您能否发布有关表结构的更多信息,这意味着有些是重复的,但只有两列呢?

can you post more information about the table structure and what do you mean that some are duplicate but only by two columns ?

无论如何,您可以查看GROUP BYCOUNTHAVING

Anyway, you can look into the GROUP BY, COUNT, and HAVING

SELECT `duped_field1`, `duped_field2`, COUNT(*) `tot`
FROM `table`
GROUP BY `duped_field1`, `duped_field2`
HAVING `tot` > 1

这篇关于mysql从数据库中仅选择重复记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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