Need help Updating data from two database and two tables
I am trying to update data from anot开发者_运维知识库her table/databases
Database 1 = Client, Table 1 = Customer$
Account Number, Zip and Phone
Database 2 = Site10 and Insurance
Need to update Site 10 with Zip from Database 1 which is the client
Need Help????
You didn't provide the key fields to link the two tables together, so, assuming these databases both reside on the same server, and assuming that "AccountNumber" in the "Customer$" table in Database 1 is the key to the Site10 table in Database2:
UPDATE Database2.Site10
SET Zip=Database1.Customer$.Zip
INNER JOIN Database1.Customer$
ON Database1.Customer$.AccountNumber = Database2.Site10.AccountNumber
If "INNER" is not valid on your particular database, this should also work:
UPDATE Database2.Site10
SET Zip=Database1.Customer$.Zip
FROM Database2.Site10, Database1.Customer$
WHERE Database2.Site10.AccountNumber = Database1.Customer$.AccountNumber
精彩评论