Merging two different databases

Viewed 28

For a hobby project, I am populating a database. At some point, I need to fill missing data from my database, with data I find in another database (if it is there). In this case, the databases in question are:

db1: https://bitbucket.org/jupiter126/simpleveggiegarden/src/main/simpleveggiegarden.sql and<br>

db2: https://www.itis.gov/downloads/itisMySQLTables.tar.gz

I could easily do this in bash, by doing 3 queries for every line - but a 100% mariadb (or mysql) way of merging such databases would certainly be much more efficient.

pseudocode would look like:

in db1:
select nomen from taxon_Plantae where nomen_en is NULL;
for each $result we get
    in db2:
    select vernaculars.vernacular_name, 
            longnames.completename,vernaculars.language 
    from longnames 
        inner join vernaculars on longnames.tsn=vernaculars.tsn 
    where vernaculars.language='english' 
    and longnames.completename='$result' 
    limit 1;
    if this $result2 is not empty, then
        in db1:
            update taxon_Plantae 
                set nomen_en='$result2' 
            where nomen='$result'

Is there a way to implement this completely in mariadb/mysql?

0 Answers
Related