Jump to content

Archived

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

grace5

Import Data form one DB to another

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)

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.