condition - Add a word based on the column presents in MySQL -


consider coulumn_name1 = 'surgery'

consider coulmn_name2 = 'leg'

concat_ws(column_name1, ' on', column_name2)

consider column_name1 = null above operation give ' on leg' if coulumn_name1 null don't want add ' on '. i used

concat_ws( column_name1, if(coulumn_name1 null, '' ,' on '), column_name2)

it's working fine. it's looking ugly. there simpler way it? in advance.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -