用case更新列

时间:2016-09-20 14:11:27

标签: mysql sql

如何解决第二种情况ELSE (LEFT JOIN)?第一个进展顺利。

UPDATE base_bw A 
SET A.Macro= 
CASE WHEN A.Cod1    IN ('213','233','236','239','272','287','296','299','311','314','330','346')
THEN 'Don't Change'
    ELSE 
    LEFT JOIN base_fix B 
    ON CONCAT(A.Parc, A.FCTA, A.DescTheme) = B.Local
    SET A.Macro = B.Macro 
END;

1 个答案:

答案 0 :(得分:0)

UPDATE tableA A
JOIN tableB B
   ON CONCAT(A.Parc, A.FCTA, A.DescTheme) = B.Local   
SET A.Macro = B.Macro 
WHERE A.Cod1   NOT IN ('213','233','236','239','272','287','296','299',
                       '311','314','330','346')