Re: SELECT Field1 || Field2 FROM Table

From: Alex Pilosov <alex(at)pilosoft(dot)com>
To: Jean-Michel POURE <jm(dot)poure(at)freesurf(dot)fr>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: SELECT Field1 || Field2 FROM Table
Date: 2001-06-13 15:49:03
Message-ID: Pine.BSO.4.10.10106131148190.17529-100000@spider.pilosoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Yes, that's correct behaviour. Any operation on null will yield null.

What you need to do:
select coalesce(field1,'') || coalesce(field2,'') ...

-alex

On Wed, 13 Jun 2001, Jean-Michel POURE wrote:

> Hello all,
>
> I have PostgreSQL 7.1.1 installed on a RedHat 7.1 server.
>
> When running the following query "SELECT Field1 || Field2 AS Result FROM Table"
> the result is NULL when Field2 is NULL.
>
> Same as if I use a PL/pgSQL function to concatenate Filed 1 || Field2.
>
> Did I miss something?
>
> Regards,
> Jean-Michel POURE, pgAdmin development team
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2001-06-13 15:54:28 Re: Patch to include PAM support...
Previous Message Peter Eisentraut 2001-06-13 15:40:11 Re: Re: Improving pg_hba.conf