mysql update 根据一个字段更新另一个字段

UPDATE lqcv_behavior_stat_inday a1
INNER JOIN (
	SELECT
		substring( stat_day, 1, 4 ) AS YEAR,
		substring( stat_day, 5, 2 ) AS MONTH,
		substring( stat_day, 7, 2 ) AS DAY,
		stat_day,
		id 
	FROM
		lqcv_behavior_stat_inday 
	) a2 ON a1.id = a2.id 
	SET a1.YEAR = a2.YEAR,
	a1.MONTH = a2.MONTH,
	a1.DAY = a2.DAY

你可能感兴趣的:(mysql update 根据一个字段更新另一个字段)