From: | "Leif B(dot) Kristensen" <leif(at)solumslekt(dot)org> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Concatenation through SQL |
Date: | 2007-12-21 11:16:45 |
Message-ID: | 200712211216.45186.leif@solumslekt.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Friday 21. December 2007, Philippe Lang wrote:
>(SELECT CONCAT(name, ', ') FROM employees AS e where e.appointment_id
> = appointments.id) AS employees
>FROM appointments
>------------------------------
>
>... where CONCAT suggest we want to concatenate the variable inside,
>with the separator ', ' inbetween.
I've got a similar problem. My persons table has a number of fields for
different name parts: given, patronym, toponym, surname, occupation,
epithet. I've written a Plpgsql function that concatenates the full
name, but it's big and ugly. I'd like something more elegant, like the
Python or PHP join() function. I tried Andreas' suggestion like this:
pgslekt=> select array_to_string(array(select given, patronym, toponym
from persons where person_id=57), ' ');
ERROR: subquery must return only one column
Is there any way to accomplish this from Plpgsql?
--
Leif Biberg Kristensen | Registered Linux User #338009
http://solumslekt.org/ | Cruising with Gentoo/KDE
My Jazz Jukebox: http://www.last.fm/user/leifbk/
From | Date | Subject | |
---|---|---|---|
Next Message | imad | 2007-12-21 11:51:58 | Re: Concatenation through SQL |
Previous Message | Pavel Stehule | 2007-12-21 11:07:17 | Re: Concatenation through SQL |