Combined use of MySql INSERT, SELECT statements gives a very easy method to insert records from another table. You can use solely MySql commands in query console.
So if you want to use copy a large amount of data to another table, you can use INSERT, SELECT commands combined.
In this example, we are copying the old customer table records to a new customer records table.
Use the following SQL query to insert data from one table to another in MySQL.
INSERT INTO customers_migrated (user_id, firstname, email, created_at)
SELECT firstname, email, created_at
FROM customers ORDER BY user_id ASC
Make sure your INSERT statement rows are matching with SELECT statement rows, otherwise will produce column matching errors.
- Just want to thank us? Buy us a Coffee
- May be another day? Shop on Amazon using our links.
Your prices won't change but we get a small commission.
Leave a Reply