mysql - update all rows at once with different where condition my sql -


i have table name details in there 2 columns. first 1 name , second gender. table consist around 50 entries of names , gender male/female. trying update gender column contains male , female both according person gender. want change data gender = male female , female male

here's query i've tried:

update details  set    gender = 'm',         gender='f'   gender = 'm';  

if need in 1 statement, try using case statement instead:

update  details  set     gender = case when gender = 'm' 'f' else 'm' end    gender in ('m', 'f') 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -