衫裤跑路 2009-03-27 04:22 采纳率: 50%
浏览 169
已采纳

在 MySQL 中查找重复值

I have a table with a varchar column, and I would like to find all the records that have duplicate values in this column. What is the best query I can use to find the duplicates?

转载于:https://stackoverflow.com/questions/688549/finding-duplicate-values-in-mysql

  • 写回答

21条回答 默认 最新

  • MAO-EYE 2009-03-27 04:24
    关注

    Do a SELECT with a GROUP BY clause. Let's say name is the column you want to find duplicates in:

    SELECT name, COUNT(*) c FROM table GROUP BY name HAVING c > 1;
    

    This will return a result with the name value in the first column, and a count of how many times that value appears in the second.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(20条)

报告相同问题?

悬赏问题

  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable