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' 
FROM posts ORDER BY id ASC 

8 Comments

  1. Babita Said...
  2. Joshwa Said...
  3. Aldy Said...
  4. Rani Kavade Said...
  5. Srinivas Said...
  6. NANDHA KUMAR Said...
  7. Ashik Said...
  8. Sanjay Krishnamurthy Said...

Leave a reply

keyboard_double_arrow_up