Batista F Batista F - 2 months ago 7
MySQL Question

Update column with case

How do I fix the second case

ELSE (LEFT JOIN)
? The first is going well.

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;

Answer
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')