Remove duplicate rows in MySQL

前端 未结 25 4253
囚心锁ツ
囚心锁ツ 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:08

    Delete duplicate rows with the DELETE JOIN statement:

    DELETE t1 FROM table_name t1
    JOIN table_name t2
    WHERE
        t1.id < t2.id AND
        t1.title = t2.title AND t1.company = t2.company AND t1.site_id = t2.site_id;
    

提交回复
热议问题