Detect duplicate records in MySQL

0

I want to find records that are exactly the same in all their fields and show them. I have the following table:

I apply the following query:

SELECT * 
FROM control 
WHERE (no IN(SELECT no 
             FROM control 
             GROUP BY no
             HAVING COUNT(*)>1)
       ) 
      AND (clave IN(SELECT clave 
                    FROM control  
                    GROUP BY clave 
                    HAVING COUNT(*)>1)
          ) 
      AND (nombre IN(SELECT nombre 
                     FROM control
                     GROUP BY nombre 
                     HAVING COUNT(*)>1)
          )
      AND (resultado IN(SELECT resultado
                        FROM control 
                        GROUP BY resultado 
                        HAVING COUNT(*)>1)
          )

But as a result, he throws this at me:

I should only throw the first four as they coincide in all their fields.

    
asked by Rafa FE 04.05.2017 в 18:09
source

1 answer

0

You could use the following query, using the GROUP BY and HAVING clause.

SELECT * FROM 'prueba' GROUP BY no,clave,nombre,resultado HAVING count(*) > 1;

Result:

    
answered by 04.05.2017 в 18:21