How to concatenate columns in a Postgres SELECT?

后端 未结 8 1679
醉酒成梦
醉酒成梦 2020-11-27 13:31

I have two string columns a and b in a table foo.

select a, b from foo returns values a and b<

8条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 13:52

    The problem was in nulls in the values; then the concatenation does not work with nulls. The solution is as follows:

    SELECT coalesce(a, '') || coalesce(b, '') FROM foo;
    

提交回复
热议问题