`

postgreSql数据库,同一字段拼接成字符串

 
阅读更多
select DISTINCT(a.orderid), array_to_string(array(SELECT opinion  from tsac_worklist), '-->') as opinion
from tsac_worklist a where orderid='402881634848bb1a014848c002110006'


另外,在sql中添加换行符,在要显示的内容后面拼接|| CHR(10) || CHR(13)则可以换行,chr(10)是换行,chr(13)是回车。
select DISTINCT(a.orderid), array_to_string(array(SELECT opinion||';'|| CHR(10) || CHR(13) from tsac_worklist
where orderid in (select m.id from tsac_orderinfo m where m.ordercode = 'GD20140926001572') ORDER BY recievetime asc limit 100 OFFSET 1), '') as opinion
from tsac_worklist a where a.orderid in (select m.id from tsac_orderinfo m where m.ordercode = 'GD20140926001572')
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics