+2 votes
in Databases by (3.7k points)
How can I select all rows from table1 and insert into table2 using SQL. I am using MySQL database.

1 Answer

0 votes
by (11.3k points)

If you want to copy all columns from table1 to table2, you can use the following query:

INSERT INTO table2
SELECT * FROM table1
WHERE condition; 

If you want to copy some selected columns from table1 to table2, you can use the following query:

INSERT INTO table2 (column1, column2, column3, ...)
SELECT column1, column2, column3, ...
FROM table1
WHERE condition;

Related questions

+3 votes
1 answer
+2 votes
1 answer
+2 votes
1 answer
...