I have a question about MySql. I have a table with 7.479.194 records. Some records are duplicated. I would like to do this:
insert into new_table
select *
This will populate NEW_TABLE with unique values, and the id value is the first id of the bunch:
INSERT INTO NEW_TABLE
SELECT MIN(ot.id),
ot.city,
ot.post_code,
ot.short_ccode
FROM OLD_TABLE ot
GROUP BY ot.city, ot.post_code, ot.short_ccode
If you want the highest id value per bunch:
INSERT INTO NEW_TABLE
SELECT MAX(ot.id),
ot.city,
ot.post_code,
ot.short_ccode
FROM OLD_TABLE ot
GROUP BY ot.city, ot.post_code, ot.short_ccode