sql - How to update newly added column in mysql -


enter image description here

hi

i have added new column "hours" , want update column. wrote following code didn't work. problem of following code?

update officer set hours=5 , hours=4 , hours=4 , hours=3 name in('kasun','manel','lala'); 

if want populate new column values, use update case when like:

update officer    set hours = case when name = 'kasun' 5                     when name = 'manel' 4                     when name = 'lala'  3                end  name in('kasun','manel','lala');  ; 


in case want populate rows random numbers, generate random number like:

update officer    set hours = abs(checksum(newid()) % 6) + 1  name in('kasun','manel','lala');  ; 

the abs(checksum(newid()) % 6) + 1 generate random number between 1 , 6


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -