pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kenneth B Hill <ken@scottshill.com>
To: George Handin <postgresql@dafunks.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Concat two fields into one at runtime
Date: Thu, 08 Jun 2006 08:54:01 -0700
Message-ID: <1149782041.1645.19.camel@localhost> (raw)
In-Reply-To: <44884736.3080309@dafunks.com>
References: <44884736.3080309@dafunks.com>

On Thu, 2006-06-08 at 10:50 -0500, George Handin wrote:
> Is there a way using built-in PostgreSQL functions to combine two data 
> fields into a single field at runtime when querying data?
> 
> For example, the query now returns:
> 
> id    first    last
> ---   -------  ----------
> 1     Goerge   Handin
> 2     Joe      Rachin
> 
> I'd like it to return:
> 
> id    name
> ---   -------------------
> 1     George Handin
> 2     Joe Rachin
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings

Try this:

SELECT id, first || || last AS name
FROM table;

-Ken




view thread (5+ messages)  latest in thread

Message-ID: <1149782041.1645.19.camel@localhost>
Permalink:  ../1149782041.1645.19.camel@localhost/
Also on:    postgresql.org/message-id/1149782041.1645.19.camel@localhost

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ken@scottshill.com, postgresql@dafunks.com
  Subject: Re: Concat two fields into one at runtime
  In-Reply-To: <1149782041.1645.19.camel@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox