sql query select between two tables and update data between that two tables

I have 2 databases with same table name,

Database one name DB1 with table name table1 :

id| dv_no | name

1 | 15-101| mics

Database two name DB2 with table name table1 :

id| dv_no | name

1 | 16-101| juan

Both dv_no is unique in both database.

My question is I want a query to select between two table in different database and update the name fields using dynamic dv_no as condition


You can update the values using below query

Update db1.table1 set db1.table1.name=db2.table1.dv_no where db1.table1.dv_no=db2.table1.dv_no

You can select using below query

Select * from db1.table1
Union all
Select * from db2.table1
链接地址: http://www.djcxy.com/p/94234.html

上一篇: 如何将Data One数据库插入另一个数据库

下一篇: sql查询在两个表之间进行选择并更新这两个表之间的数据