sql >> Databasteknik >  >> RDS >> Mysql

MySQL tar bort dubbletter av rader

DELETE FROM comments c1 

WHERE EXISTS (
    SELECT * 
    FROM comments c2 
    WHERE c2.id <> c1.id 
        AND c2.name = c1.name 
        AND c2.email = c1.email 
        AND c2.comment = c1.comment
)

AND c1.id <> (
    SELECT MIN(c2.id) 
    FROM comments c2 
    WHERE c2.name = c1.name 
        AND c2.email = c1.email 
        AND c2.comment = c1.comment
)



  1. Socketfil /var/pgsql_socket/.s.PGSQL.5432 saknas i Mountain Lion (OS X Server)

  2. SQLite Union

  3. Varför påverkas två rader i min `INSERT ... ON DUPLICATE KEY UPDATE`?

  4. MySQL:Union of a Left Join with a Right Join