0

I am selecting with concat from a table with Name and Notes fields. I am putting the notes in open and close parentheses. In the cases where the Notes field is NULL I don't want any () as the first Select does:

Select concat(Name,(concat(' (',Notes,')'))) from Table

which gives me:

  • Name1 (Notes1)
  • Name2 ()

I tried concat_ws

Select concat(Name,(concat_ws('(',Notes,')'))) from Table

but this gives me

  • Name1Notes1()
  • Name2)

And ifnull didn't work at all.

I'd prefer to not do this with Case/Then because I have many tables I am concatenating using left join and it would make an already complex query unwieldy.

user3649739
  • 1,829
  • 2
  • 18
  • 28

0 Answers0