Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to copy row(s) into same Table

Status
Not open for further replies.

Delphard

Programmer
Jul 22, 2004
144
RS
Is there some easy way to copy row(s) from/to same Table?

MySQL HELP says (in 13.1.4.1 INSERT ... SELECT Syntax): "Currently, you cannot insert into a table and select from the same table in a subquery."

Thanks in advance!
 
use table aliases

Bastien

I wish my computer would do what I want it to do,
instead of what I tell it to do...
 
I used to have this kind of situation in Oracle.
I used to do it in "work around" way.

1.Create a temp table of same structure of original table.
2. Do a " Insert into Temp_table values select * from Original_Table.
3.Then Using the same style of insert statement , Insert the rows from the temp_table to Original Table.

This methos id advantageous as this will not mess up you original table as you have a backup of original table(i.e ut temp table)
(provided, there cannot be duplicate constraint)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top