I need to insert one of each duplicate name from one table into another.
And duplicates only.
The following query lists all duplicate names and the count:
select name, count(name) as cnt
from my_table
group by name
having cnt > 1
order by name
How can I insert one of each occurrence into another table?
Update
My tables are not identical.
My new table only has the following rows:
id (auto increment)
name (varchar)
First create table.
Then insert data to new table:
Consult 12.2.5.1. INSERT … SELECT Syntax for detailed information.
EDITED
You can specify columns name or order, for example:
For your table, you need to create another field to store
cnt: