Re: What is || doing

From: Thom Brown <thom(at)linux(dot)com>
To: Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: What is || doing
Date: 2011-06-27 13:12:08
Message-ID: BANLkTiksAZGbx5_11_aNEKz6H_gjyZBVpw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On 27 June 2011 13:59, Frank Lanitz <frank(at)frank(dot)uvena(dot)de> wrote:
> Hi list,
>
> I've got an query which contains || inside the select statement and I'm
> not sure, what this is doing. Can you help me out a bit or send me a
> link to documentation where I can find this?
>
> Example:
>
> SELECT 'ba_'|| foo || '_pr_'
> FROM 'foobaa'
> WHERE id=1234;

|| in PostgreSQL is a concatenation operator. It's equivalent to + in
Microsoft SQL Server, or concat() in MySQL.

So if foo = 'hello', the output of that select would be 'ba_hello_pr_'

See http://www.postgresql.org/docs/current/static/functions-string.html

Regards

Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Jean-Yves F. Barbier 2011-06-27 13:13:46 Re: What is || doing
Previous Message Frank Lanitz 2011-06-27 12:59:30 What is || doing