Finding duplicate values in MySQL

前端 未结 25 2477
执笔经年
执笔经年 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:52

    I saw the above result and query will work fine if you need to check single column value which are duplicate. For example email.

    But if you need to check with more columns and would like to check the combination of the result so this query will work fine:

    SELECT COUNT(CONCAT(name,email)) AS tot,
           name,
           email
    FROM users
    GROUP BY CONCAT(name,email)
    HAVING tot>1 (This query will SHOW the USER list which ARE greater THAN 1
                  AND also COUNT)
    

提交回复
热议问题