postgre ||连接字段

在Postgre中使用||符号可以将字段内容拼接起来,如下
select code||name as codeName from myTable
但是要注意的是,如果拼接的字段中有null值那么拼接的返回结果会变成null
可以使用
coalesce对null值赋个空字符串解决,如下
select coalesce(code,'')||coalesce(name,'') as codeName from myTabl
posted @ 2020-06-16 10:39  Cyril-Hcj  阅读(329)  评论(0编辑  收藏  举报