INSERT SQL - Clone a column in MySQL

It is possible to use two SQL syntaxes to copy data from one table in the database to another:

The first syntax if the two tables have the same schema:

INSERT INTO table2
SELECT * FROM table1
Otherwise, You must specify the column names you want to copy (the column list is optional for 'table2' if you are specifying a value for all columns and selecting the columns in the same schema order of 'table2'.

INSERT INTO table2(col1, col2, col3)
SELECT col1, col2, col3
FROM table1

Advertisement

AdBlock Detected

Please disable your ad blocker and refresh the window to use this website.