Thursday, May 13, 2010

Copying selected record from one MySQL table to another

In the case of existing table with the same structure:
INSERT table2 SELECT * FROM table1 WHERE [conditions]

Alternative syntax for a table with different structure:
INSERT table2 (columnA, columnB) SELECT column1, column2 FROM table1 WHERE [conditions]

No comments:

Post a Comment