In the table there are more than 3 tons of records with the same content, how can you delete them in one query? Suppose if the table in one of the fields has the same text.

    1 answer 1

    Let the main table table1 contain fields: id (int not null auto_increment primary key), data (varchar). There are duplicates in the data field. You can remove duplicates for example:

    1. create a new table table2 (copy of table1 table):

      insert into table2 (select * from table1);

    2. remove duplicates from the main table:

      delete from table1 where id is not in (select min (id) from table2 group by data);

    3. remove table table2:

      drop table table2;

    And you can immediately select only unique entries in the data field from table1.