其实mysql中update和select结合使用就是用内连接完成的
- UPDATE
FIN_CERTIFICATE_SOURCE a INNER JOIN (
SELECT
fcs.ID,
ftri.TAX_RATE_TYPE
FROM
FIN_CERTIFICATE_SOURCE fcs
LEFT JOIN
FIN_TAX_RATE_ITEM ftri ON fcs.FEE_TYPE = ftri.DICT_CODE
WHERE
fcs.MALL_ID = 5
AND fcs.INPAY_TYPE IN ('1002', '1003', '1005')
AND fcs.TAX_TYPE IS NULL
AND ftri.RATE_ID = '33'
) as b ON b.id = a.id
SET a.TAX_TYPE = b.TAX_RATE_TYPE;