Jump to content

Import Data form one DB to another


grace5

Recommended Posts

How can I use an existing MySQL DBs data in another MySQL DB that does not contain the same fields?

 

I have several hundreds of URLs in a DB that I want to move to another directory that has not the same structure /fields.

 

(I hope this makes sense as I am a dummie with MySQL)

Link to comment
https://forums.phpfreaks.com/topic/2788-import-data-form-one-db-to-another/
Share on other sites

use INSERT INTO ... SELECT

[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']INSERT[/span] INTO db2.mytable [span style=\'color:blue;font-weight:bold\']SELECT[/span] field1,field2 FROM db1.mytable // or [span style=\'color:blue;font-weight:bold\']INSERT[/span] INTO db2.mytable (field1,field2) [span style=\'color:blue;font-weight:bold\']SELECT[/span] field1, field2 FROM db1.mytable [!--sql2--][/div][!--sql3--]

You can add WHERE and ORDER BY to the SELECT part just like a regular SELECT. Make sure the column count and data types match db2.mytable.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.