【问题标题】:How to Update different database?如何更新不同的数据库?
【发布时间】:2018-12-01 18:27:42
【问题描述】:

如何将数据从数据库“testing”更新到“testing2”两者具有相同的列。

Sample Image

【问题讨论】:

  • 这对您有帮助吗? stackoverflow.com/questions/3502269/…
  • 到目前为止你尝试过什么?这应该有据可查
  • @NicoHaase 仅适用于 testingtesting2 没有像 testing 这样的数据。
  • 不过,你有什么尝试?

标签: mysql sql database localhost


【解决方案1】:
UPDATE testing2.tbl_customer c1
INNER JOIN testing.tbl_customer c2 ON c1.CustomerID = c2.CustomerID 
SET c1.CustomerName = c2.CustomerName,
    c1.Address = c2.Address, 
    c1.City = c2.City, 
    c1.PostalCode = c2.PostalCode, 
    c1.Country = c2.Country

【讨论】:

  • first ans 和你的有区别吗?
【解决方案2】:

只需使用 databasename.tablename.column 将一个数据库更新为不同的数据库表

例子

    update testing.tbl_customer 
inner join testing2.tbl_customer
on testing.tbl_customer.CustomerID=testing2.tbl_customer.CustomerID

set testing.tbl_customer.CustomerName=testing2.tbl_customer.CustomerName

如果您想更新更多列,只需使用 coma 并将列名放入 set cluase

【讨论】:

  • 我不明白 RA.Sales tblAccounts tblSalesRepsAccountLink AccountCode 你从哪里得到的?
  • @Noob 是第二个数据库的别名和它的表名,你能分享你的数据库名和表名,以便我可以用你的做例子
  • 只需点击示例图片
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-03-14
  • 1970-01-01
  • 2017-04-15
  • 2018-04-25
相关资源
最近更新 更多