Re: Concatenation in SELECT - Mailing list pgsql-general

From Manfred Koizar
Subject Re: Concatenation in SELECT
Date
Msg-id dv5srvom8fi7vog260mun6oukreh3cu78r@email.aon.at
Whole thread Raw
In response to Concatenation in SELECT  (Alex <alex@meerkatsoft.com>)
List pgsql-general
On Fri, 21 Nov 2003 20:22:17 +0900, Alex <alex@meerkatsoft.com> wrote:
>Hi,
>is it possible to concatenate two rows (same or different data type)
>into one.
>like First Name, Last Name   or ZIP City  etc.

If you meant to concatenate two *columns*, it goes like

    SELECT firstname || ' ' || lastname AS fullname FROM ...

or for nullable columns

    SELECT coalasce(firstname || ' ', '') ||
           coalesce(lastname, '') AS ...

This should work for non-text datatypes as well, because most, if not
all, datatypes have implicit casts to text.

Servus
 Manfred

pgsql-general by date:

Previous
From: Denis Gasparin
Date:
Subject: Bug in pg_dumpall
Next
From: Oleg Bartunov
Date:
Subject: Re: tsearch2 column update produces "word too long"