pheromix pheromix - 5 months ago 9
MySQL Question

How to insert records from a database into another database table?

I have two

databases
and I want to
insert
the results of a
query
from the first
database
into another table in the second
database
. How to do that using MySQL ?

Answer

If both databases are on same system you may try something like, In the below example data is migrated from oldDatabase table1 to newDatabase table1. This is the basic example, you can do your variation of query with it.

INSERT INTO newDatabase.table1 (column1, column2) 
SELECT column1, column2 FROM oldDatabase.table1;
Comments