X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 100D09FA6B0 for ; Thu, 8 Jun 2006 13:04:38 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 73273-04 for ; Thu, 8 Jun 2006 13:04:29 -0300 (ADT) X-Greylist: delayed 00:10:25.508638 by SQLgrey- Received: from sccrmhc14.comcast.net (sccrmhc14.comcast.net [204.127.200.84]) by postgresql.org (Postfix) with ESMTP id 755529FA6B1 for ; Thu, 8 Jun 2006 13:04:29 -0300 (ADT) Received: from [10.0.1.6] (c-24-20-199-254.hsd1.or.comcast.net[24.20.199.254]) by comcast.net (sccrmhc14) with SMTP id <2006060815540101400msghje>; Thu, 8 Jun 2006 15:54:02 +0000 Subject: Re: Concat two fields into one at runtime From: Kenneth B Hill Reply-To: ken@scottshill.com To: George Handin Cc: pgsql-sql@postgresql.org In-Reply-To: <44884736.3080309@dafunks.com> References: <44884736.3080309@dafunks.com> Content-Type: text/plain Organization: Scotts Hill Associates, Inc. Date: Thu, 08 Jun 2006 08:54:01 -0700 Message-Id: <1149782041.1645.19.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/101 X-Sequence-Number: 25337 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