有a,b两个表,
其中a表中有两个字段,分别为a.pay_bank_code,a.pay_account_no;
其中b表有两个字段,分别为b.in_code,b.bank_code,
两个表中a.pay_account_no=b.in_code,记录非单行,
现在需要根据a表中pay_account_no和b表中的in_code对应关系,将b表的bank_code更新到a表的pay_bank_code。
其中a表中有两个字段,分别为a.pay_bank_code,a.pay_account_no;
其中b表有两个字段,分别为b.in_code,b.bank_code,
两个表中a.pay_account_no=b.in_code,记录非单行,
现在需要根据a表中pay_account_no和b表中的in_code对应关系,将b表的bank_code更新到a表的pay_bank_code。
where a.pay_account_no=b.in_code
)
set pay_bank_code=bank_code
update a set pay_bank_code=(select bank_code from b where a.pay_account_no=b.in_code)
SET A.PAY_BANK_CODE = (SELECT MAX(B.BANK_CODE)
FROM B
WHERE A.PAY_ACCOUNT_NO = B.IN_CODE)
WHERE EXISTS (SELECT 1
FROM B
WHERE A.PAY_ACCOUNT_NO = B.IN_CODE);