mysql insert table from another table

Insert data from one table into another in MySQL
Let’s say you need to copy data from one table into another. You can insert data from table into another in MySQL.

The INSERT INTO SELECT statement copies data from one table to another. Existing rows in the target table are unaffected.

Syntax
Insert data from one table into another for all columns,

INSERT INTO table2
SELECT * FROM table1;


Insert data from one table into another for specific columns,

INSERT INTO table2
column1, column2..
SELECT column1, column2, ..
FROM table1;

from : http://blog.ubiq.co/insert-data-from-one-table-into-another-mysql/

แสดงความคิดเห็น

0 ความคิดเห็น