Re: Concatenation Operator: Is this a bug? - Mailing list pgsql-general

From Peter Eisentraut
Subject Re: Concatenation Operator: Is this a bug?
Date
Msg-id Pine.LNX.4.30.0103180036250.4749-100000@peter.localdomain
Whole thread Raw
In response to Concatenation Operator: Is this a bug?  ("Matt Friedman" <matt@daart.ca>)
List pgsql-general
Matt Friedman writes:

> The following query behaves as I would expect if all the columns mentioned
> have a value in them. If any of the columns are null however, the whole row
> returns but it's blank.

Correct.

> SELECT
>   title || ' ' || author || ' ' || description || ' ' || excerpt_title || '
> ' || excerpt_intro || ' ' || excerpt AS text
> FROM
>   books;
>
> Is this an issue with null being considered a "non" value?

Sort of.  More precisely, it's an issue with following the SQL standard.

> Would a cast on the columns help?

No.

> Perhaps there is an ifnull return someting function?

COALESCE(colname, 'value-if-null')

--
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/


pgsql-general by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: Concatenation Operator: Is this a bug?
Next
From: "Moishe Groger"
Date:
Subject: Cannot start postmaster