Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.