Reputation: 435
I have a table with 1000 records, I want to insert the same number of records again so that the total record count will be 2000. Is there a way I can Insert same records into the same table again and again:
For example:
SELECT * from MyTable ; has 1000 records
I want to do something like the following:
INSERT INTO Mytable ( All the records from above table) ;
Please advise. Thanks !!
Upvotes: 0
Views: 78
Reputation: 24002
You can use, INSERT INTO .... SELECT
syntax. And you can also LIMIT
the number of records to be copied.
INSERT INTO Mytable SELECT * from Mytable LIMIT 0, 1000;
But this would fail, if you have a unique data field in the table and you are trying to copy the same again. You have to be cautious in such cases.
If you can omit auto increment primary column and select specific columns to copy, then you have to include those column names with insert
.
Example:
INSERT INTO Mytable ( col2, col3, ... )
SELECT
col2, col3, ...
FROM Mytable
LIMIT 0, 1000;
Upvotes: 2