Not easy, AFAIK. With PHP, this should not be too complicated (I donβt think you can easily do this just by using SQL).
Create a new table with the same structure as the original:
CREATE TABLE dev_discs_noduplicates (...);
Extract all non-duplicated data from the source table with the GROUP clause to eliminate duplicates:
SELECT * FROM dev_discs WHERE 1 GROUP BY dupe_col1, dupe_col2;
Scroll through the results and paste them into a new table:
INSERT INTO dev_discs_noduplicates ...;
Delete old table
DROP TABLE dev_discs;
Rename the new table:
RENAME TABLE dev_discs_nodulicates TO dev_discs;
[EDIT]
Since @xanatos rightfully noticed a possible loss of relations in the database, here is an alternative solution that includes SQL and PHP.
First select the unique lines:
SELECT id FROM dev_discs GROUP BY col1, col2;
Having them in a PHP array, insert it and use it in the delete request:
DELETE FROM dev_discs WHERE (id) NOT IN ( @arr );
This should take care of all possible problems.
source share