SQL update from one Table to another based on a ID match

后端 未结 22 1593
太阳男子
太阳男子 2020-11-21 22:49

I have a database with account numbers and card numbers. I match these to a file to update any card numbers to the account number, so

22条回答
  •  一个人的身影
    2020-11-21 23:34

    Thanks for the responses. I found a solution tho.

    UPDATE Sales_Import 
    SET    AccountNumber = (SELECT RetrieveAccountNumber.AccountNumber 
                              FROM   RetrieveAccountNumber 
                              WHERE  Sales_Import.leadid =RetrieveAccountNumber.LeadID) 
    WHERE Sales_Import.leadid = (SELECT  RetrieveAccountNumber.LeadID 
                                 FROM   RetrieveAccountNumber 
                                 WHERE  Sales_Import.leadid = RetrieveAccountNumber.LeadID)  
    

提交回复
热议问题