mysql - Unable to update multiple records with one single query (CASE/WHEN)) -


i trying update multiple records few columns in table in sql following query.

(i wish update a1, b b1, c c1 , on..)

update employee  set case when name ='a'  'a1' end      case when name ='b'  'a2' end      case when name ='c'  'a3' end     case when name ='d'  'a4' end      case when name ='e'  'a5' end      case when name ='f'  'a6' end      case when name ='g'  'a7' end      case when name ='h'  'a8' end      case when name ='j'  'a9' end      case when name ='k'  'b0' end      case when name ='l'  'b1' end ,     case when category = 'recrods' 'records' end ,     case when featureid ='140' 'cv5' end     school = '5000'  

getting error : incorrect syntax near keyword 'case'. sure missing here.

please me. lot in advance :)

you need column first thing after set. perhaps:

update employee      set name = (case when name ='a'  'a1'                       when name ='b'  'a2'                       when name ='c'  'a3'                      when name ='d'  'a4'                       when name ='e'  'a5'                       when name ='f'  'a6'                       when name ='g'  'a7'                       when name ='h'  'a8'                       when name ='j'  'a9'                       when name ='k'  'b0'                       when name ='l'  'b1'                      else name                  end),         category = (case when category = 'recrods' 'records' else category end),         featureid = (case when featureid ='140' 'cv5' else featureid end)     school = '5000' ; 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -