Remove duplicate rows in MySQL

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

    I keep visiting this page anytime I google "remove duplicates form mysql" but for my theIGNORE solutions don't work because I have an InnoDB mysql tables

    this code works better anytime

    CREATE TABLE tableToclean_temp LIKE tableToclean;
    ALTER TABLE tableToclean_temp ADD UNIQUE INDEX (fontsinuse_id);
    INSERT IGNORE INTO tableToclean_temp SELECT * FROM tableToclean;
    DROP TABLE tableToclean;
    RENAME TABLE tableToclean_temp TO tableToclean;
    

    tableToclean = the name of the table you need to clean

    tableToclean_temp = a temporary table created and deleted

提交回复
热议问题