sql >> Database teknologi >  >> RDS >> Mysql

MySQL-liste over alle dubletter

SELECT  a.*, b.totalCount AS Duplicate
FROM    tablename a
        INNER JOIN
        (
            SELECT  email, COUNT(*) totalCount
            FROM    tableName
            GROUP   BY email
        ) b ON a.email = b.email
WHERE   b.totalCount >= 2

for bedre ydeevne skal du tilføje en INDEX i kolonne EMail .

ELLER

SELECT  a.*, b.totalCount AS Duplicate
FROM    tablename a
        INNER JOIN
        (
            SELECT  email, COUNT(*) totalCount
            FROM    tableName
            GROUP   BY email
            HAVING  COUNT(*) >= 2
        ) b ON a.email = b.email


  1. Flere showplan-forbedringer? Ja tak!

  2. psycopg2:indsæt flere rækker med én forespørgsel

  3. SQL-udvikler 4.1.2

  4. Opret et ER-diagram i pgAdmin