user3649739
user3649739

Reputation: 1869

Concat with conditional inner concat

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:

I tried concat_ws

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

but this gives me

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.

Upvotes: 0

Views: 32

Answers (0)

Related Questions