mysql数据根据本表字段修改另一字段数据及关联外表修改本表字段数据
UPDATE point SET state = CASE
WHEN end_date<NOW() THEN
'3'
WHEN start_date>NOW() THEN
'2'
ELSE
'1'
END WHERE is_delete ='0'
-- 风险中风险点启用状态初始化
UPDATE source a
LEFT JOIN point b ON a.risk_point_id = b.id
AND b.is_delete = '0'
SET a.risk_point_enable_state = (
CASE
WHEN b.risk_point_enable_state IS NULL THEN '1'
ELSE
b.risk_point_enable_state
END
)
WHERE
a.is_delete = '0'