Re: how to concatenate in PostgreSQL - Mailing list pgsql-sql

From Allan Kamau
Subject Re: how to concatenate in PostgreSQL
Date
Msg-id CAF3N6oRbzLfKqRTW6fZoAciqV5qSO2i3+SrtV6=HdtW97oX3Ag@mail.gmail.com
Whole thread Raw
In response to Re: how to concatenate in PostgreSQL  (Andreas Kretschmer <akretschmer@spamfence.net>)
List pgsql-sql
On 3/24/12, Andreas Kretschmer <akretschmer@spamfence.net> wrote:
> Rehan Saleem <pk_rehan@yahoo.com> wrote:
>
>> hi ,
>> how can we concatinate these lines and execute sql command
>>
>>        set sql = 'select user,username, firstname '
>>       set sql += ' lastname, cardno from table1 where userid=' + 5
>
> sql = sql || ' bla fasel';
>
> || is the concat - Operator.
>
>
>
> Andreas
> --
> Really, I'm not out to destroy Microsoft. That will just be a completely
> unintentional side effect.                              (Linus Torvalds)
> "If I was god, I would recompile penguin with --enable-fly."   (unknown)
> Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>


You may want to ensure that none of variables to be concatenated is
NULL, else the end result will be NULL.
"coalesce" function provides means to provide an substitute value for
a variable that may be NULL.

Allan.


pgsql-sql by date:

Previous
From: Andreas Kretschmer
Date:
Subject: Re: how to concatenate in PostgreSQL
Next
From: Rehan Saleem
Date:
Subject: MS-SQL to PostgreSql