php - sql table to update nulled column -


table given below

id         country       person        money     sum  1           uk           john          2010      null 2           usa          henry         120       null 3           rus          neko          130       null 4           ger          suka          110       null 7           can          beater        1450      null 8           usa          lusi          2501      null 

each money column multiply 2 , stored corresponding sum column how, given below

id         country       person        money     sum  1           uk           john          2010      4020 2           usa          henry         120       240 3           rus          neko          130       260 4           ger          suka          110       220 7           can          beater        1450      2900 8           usa          lusi          2501      5002 

you want update field using expression this.

update `tablename` set `sum` = `money` * 2 `sum` null; 

if want happen indescriminately can drop portion of update like:

update `tablename` set `sum` = `money` * 2; 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -