sql - mysql what is the right syntax for this conditional update statement -


mysql, want like

update tablename   case fielda  when value1 set fieldx0=xxx,fieldx1=bbb,fieldx2=ccc ...  when value2 set fieldy0=yyy,fieldy1=eee,fieldy2=fff ...  end 

what right , simple syntax it? thank much.

it should written way:

update tablename set fieldx = case when fielda = 'value1' 'xxx' else fieldx end,     fieldy = case when fielda = 'value2' 'yyy' else fieldy end fielda in ('value1', 'value2');  

note that: wrote else part way, because default else null if condition of case expression not valid, set original value not null value.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -