Jump to content


Photo

Import Data form one DB to another


  • Please log in to reply
1 reply to this topic

#1 grace5

grace5
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 02 November 2005 - 05:45 PM

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)

#2 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 02 November 2005 - 06:36 PM

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.
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users