How best to turn select result into options like 'a|b|c''

Started by Shaozhong SHIover 4 years ago3 messagesgeneral
Jump to latest
#1Shaozhong SHI
shishaozhong@gmail.com

Is there a way to turn select result into something like 'a|b|c' .
Regards,
David

#2Ray O'Donnell
ray@rodonnell.ie
In reply to: Shaozhong SHI (#1)
Re: How best to turn select result into options like 'a|b|c''

On 20 December 2021 22:10:19 Shaozhong SHI <shishaozhong@gmail.com> wrote:

Is there a way to turn select result into something like 'a|b|c' .
Regards,
David

On my phone so hard to reply properly, but if a, b and c are in separate
rows then you need the array_agg() and array_to_string() functions.

Ray.

#3David G. Johnston
david.g.johnston@gmail.com
In reply to: Ray O'Donnell (#2)
Re: How best to turn select result into options like 'a|b|c''

On Mon, Dec 20, 2021 at 3:24 PM Ray O'Donnell <ray@rodonnell.ie> wrote:

On 20 December 2021 22:10:19 Shaozhong SHI <shishaozhong@gmail.com> wrote:

Is there a way to turn select result into something like 'a|b|c' .
Regards,
David

On my phone so hard to reply properly, but if a, b and c are in separate
rows then you need the array_agg() and array_to_string() functions.

Or just: string_agg()

David J.