Deleting duplicate record from table - SQL query

前端 未结 7 1086
有刺的猬
有刺的猬 2021-02-03 15:09

I need to delete duplicate rows only from the table, like I have 3 duplicate rows in the table, my query will delete 2 rows from 3 duplicated rows.

How can I get this? P

7条回答
  •  时光取名叫无心
    2021-02-03 15:22

    DELETE FROM Table t1, Table t2 WHERE t1.colDup = t2.colDup AND t1.date < t2.date
    

    Will delete every duplicate row from Table (on column colDup) except the oldest (i.e. lowset date).

提交回复
热议问题