Mysql
 sql >> Teknologi Basis Data >  >> RDS >> Mysql

MySQL menghapus baris duplikat

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. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. JSON_SEARCH() – Temukan Path ke String dalam Dokumen JSON di MySQL

  2. Tabel tidak ada setelah CREATE TABLE

  3. Sisipan atau pembaruan massal Slick 3.0 (upsert)

  4. Penandaan hierarkis dalam SQL

  5. MySQL:SyntaxError:Pengidentifikasi tak terduga