主要场景应用于A表的字段cust_id是B表里面的主键ID,根据已经A表中存有的cust_code值做关联通步B表的cust_id存储到A表中cust_id中,使用主键索引查询提高查询效率
UPDATE crm_cust_message_detail d
SET d.cust_id = (SELECT
cust_id
FROM
sid_cust c
WHERE
c.cust_code = d.cust_code
),
d.createDate = (
SELECT
m.created_time
FROM
crm_cust_message m
WHERE
m.cust_message_id = d.cust_message_id
)