Remove duplicate rows in MySQL

前端 未结 25 3472
囚心锁ツ
囚心锁ツ 2020-11-21 04:33

I have a table with the following fields:

id (Unique)
url (Unique)
title
company
site_id

Now, I need to remove rows having same titl

25条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-21 05:12

    Delete duplicate rows using DELETE JOIN statement MySQL provides you with the DELETE JOIN statement that you can use to remove duplicate rows quickly.

    The following statement deletes duplicate rows and keeps the highest id:

    DELETE t1 FROM contacts t1
        INNER JOIN
    contacts t2 WHERE
    t1.id < t2.id AND t1.email = t2.email;
    

提交回复
热议问题