Search code examples
mysqlazurecleardb

how to do bulk update with from two different tables in two different databases in Azure MySQL DB?


I have two databases db1 and db2 in mySQL Azure instance. I want to bulk update a column in tbl2 from tbl1.

I want to do bulk update statement with a select statement based on a matching column value in both tables tbl1 and tbl2 but not the primary key.


Solution

  • Here is how to implement bulk update in mySQL with Select implementation using Join through two databases.

    You can do the same idea for two tables in the same database, just rename the instance name in below query!

    update db2.make
    set ImageUrl = (
    select ImageUrl
    from db1.make
    where db1.make.MakeName = db2.make.MakeName
    );