mysql return results based on column results -


i'm trying parse result

table structure

column 1  | column 2         | if_at_n  b         | if_et_n        c         | if_at_n

what i'm trying replace column 2 results "yes" if "_at present , "no" if _et present

the goal of result set like

a | no b | yes c | no

your statement not match desired output. can interchange values of yes , no fits needs.

select  column1,         if(column2 '%\_at\_%', 'no', 'yes') result    tablename 

output

╔═════════╦════════╗ ║ column1 ║ result ║ ╠═════════╬════════╣ ║       ║ no     ║ ║ b       ║ yes    ║ ║ c       ║ no     ║ ╚═════════╩════════╝ 

the query above projection. means there no modification in table. if want modify values of table, need use update statement.

update tablename set   column2 = if(column2 '%\_at\_%', 'no', 'yes') 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -