By using INSERT INTO SELECT Statement one can copy data from one table to other existing table.
Syntax:
To copy all the columns from one table to another table:
INSERT INTO table_name1 (SELECT * from table_name);
To copy only the selected columns:
INSERT INTO table_name1(column_names) (SELECT column_names from table_name);
Above, both table_name and table_name1 are existing table where:
table_name: is the table from which you will copy the data.
table_name1: is the table in which you want to insert the copied data.
Example:
INSERT INTO temp_employee (SELECT * from employee);
0 Comment(s)