[prev in list] [next in list] [prev in thread] [next in thread]
List: postgresql-general
Subject: Re: How best to turn select result into options like 'a|b|c''
From: "David G. Johnston" <david.g.johnston () gmail ! com>
Date: 2021-12-20 22:37:12
Message-ID: CAKFQuwY2norL3CZLWt9srwqwU5NE-cqTsZ5dkCzJuQL+B7kvEQ () mail ! gmail ! com
[Download RAW message or body]
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.
[Attachment #3 (text/html)]
<div dir="ltr"><div dir="ltr"><div class="gmail_default" \
style="font-family:arial,helvetica,sans-serif"><span \
style="font-family:Arial,Helvetica,sans-serif">On Mon, Dec 20, 2021 at 3:24 PM Ray \
O'Donnell <<a href="mailto:ray@rodonnell.ie">ray@rodonnell.ie</a>> \
wrote:</span><br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" \
style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"><u></u>
<div>
<div dir="auto">
<div dir="auto"><span style="font-size:10pt">On 20 December 2021 22:10:19 Shaozhong \
SHI <<a href="mailto:shishaozhong@gmail.com" \
target="_blank">shishaozhong@gmail.com</a>> wrote:</span></div><div \
id="gmail-m_-8860704564296239512aqm-original" style="color:black"><div><div \
style="color:black"> <blockquote type="cite" class="gmail_quote" style="margin:0px \
0px 0px 0.75ex;border-left:1px solid rgb(128,128,128);padding-left:0.75ex"> Is there \
a way to turn select result into something like 'a|b|c' \
.<div>Regards,</div><div>David</div></blockquote></div></div></div><div \
dir="auto"><br></div><div dir="auto">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.</div><div \
dir="auto"><br></div></div></div></blockquote><div><br></div><div \
class="gmail_default" style="font-family:arial,helvetica,sans-serif">Or just: \
string_agg()</div><div class="gmail_default" \
style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" \
style="font-family:arial,helvetica,sans-serif">David J.<br></div></div></div>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic