Reputation: 12545
I have a mysql table with 20 fields and only 5 rows. None of the fields are unique, indexed or primary keys.
I want to simply duplicate all 5 rows in the table. Is there a single SQL statement to do this?
Upvotes: 0
Views: 59
Reputation: 1024
Following query should fulfill your requirement
INSERT INTO TABLE1 SELECT * FROM TABLE1;
If you want to copy all fields from another table then,
INSERT INTO TABLE1 SELECT * FROM TABLE2;
If you want to copy only specific fields then,
INSERT INTO TABLE1(field1,field2) SELECT field1,field2 FROM TABLE2;
Please note that field count in INSERT
and SELECT
should be the same.
Upvotes: 2