How to Insert Data from One Table to Another in MySQL

MySQL INSERT … SELECT statement provides an easy way to insert rows into a table from another table. If you want to copy data from one table to another in the same database, use INSERT INTO SELECT statement in MySQL. It’s a very quick process to copy large amount data from a table and insert into the another table in same MySQL database.

In the example of INSERT ... SELECT syntax, we’ll copy data from posts table and insert into the posts_new table. You can also specify a predefined value in the SELECT statement.

Use the following SQL query to insert data from one table to another in MySQL.

INSERT INTO posts_new (user_id, title, content, status) 
SELECT published_by, title, content, '1' 

Related Articles

Comments 0