Finding duplicate values in MySQL

前端 未结 25 2563
执笔经年
执笔经年 2020-11-22 04:04

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 duplic

25条回答
  •  爱一瞬间的悲伤
    2020-11-22 04:51

    to get all the data that contains duplication i used this:

    SELECT * FROM TableName INNER JOIN(
      SELECT DupliactedData FROM TableName GROUP BY DupliactedData HAVING COUNT(DupliactedData) > 1 order by DupliactedData)
      temp ON TableName.DupliactedData = temp.DupliactedData;
    

    TableName = the table you are working with.

    DupliactedData = the duplicated data you are looking for.

提交回复
热议问题