Ajith Deivam
Ajith Deivam

Reputation: 766

My SQL--how to insert Data One database into another Database

I have two MySQL databases DB1 and DB2, DB1 is on Online server, and DB2 is on local machine(localhost), Now i want to insert some data into DB2's table named db2_table from DB1's table named db1_table using MySQL QUERY. So it is possible or not?

Upvotes: 2

Views: 567

Answers (1)

Roberto Bisello
Roberto Bisello

Reputation: 1235

if you are on the same server you can do something like

INSERT INTO DB2.db2_table (col1, col2, ..., colN) SELECT col1, col2 FROM DB1.db1_table WHERE ...

but being on different servers you can not insert data in this way... the simplest way I can think of, is to dump data from the source db (with phpmyadmin, for instance) and import it into the target db.

Upvotes: 1

Related Questions