grace5 Posted November 2, 2005 Share Posted November 2, 2005 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 More sharing options...
ryanlwh Posted November 2, 2005 Share Posted November 2, 2005 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. Link to comment https://forums.phpfreaks.com/topic/2788-import-data-form-one-db-to-another/#findComment-9322 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.