Pass data from one database to another with different tables (MySql)

1

I need to pass data from one table in a database to another database. In addition, in the new database some fields are not called the same but they must contain the same data (for example, in one table the field for cities is called "city" and in the other "location", but the data it stores are the same).

The schema of the databases is something like this:

-basedatos1
--artist
---id
---artist_name
---short_desc
---location

-basedatos2
--artist
---id
---name
---short_description
---city

It's not the real scheme, but I think it serves as an example. Neither do I need to pass all the fields, since the new table has additional fields that the old one does not have

    
asked by Borjeitor 06.03.2017 в 11:51
source

2 answers

1

In the end I did it in the following way:

INSERT INTO newDatabase.table1 (Column1, Column2) 
SELECT column1, column2 FROM oldDatabase.table1;

Thanks for the answers:)

    
answered by 06.03.2017 / 12:30
source
0

If there are not many tables I would advise you to do the export by hand creating custom SQL's by selecting the fields that match the structure of the target table. You just have to consider selecting the columns by aliasing the names of the fields in the target table.

It's a bit laborious but I think it will help you.

    
answered by 06.03.2017 в 12:25