Re: [GENERAL] combining contents of two fields into a new field?

From: "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] combining contents of two fields into a new field?
Date: 1999-02-22 18:23:41
Message-ID: 36D1A0AD.5B29F7D5@rice.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

With the || concationation operator, as so:

UPDATE dice_data SET dice_new_phone = dice_prefix || dice_phone

Note, however, that for some reason you must add axplicit parens for
multiple concats:

UPDATE dice_data SET dice_new_phone = dice_prefix || dice_phone ||
dice_suffix

won't work (yet!), but:

UPDATE dice_data SET dice_new_phone = (dice_prefix || dice_phone)||
dice_suffix

should.

William J. Stotts wrote:
>
> Hi folks,
>
> Please excuse this question for it shows my ignorance;-)
>
> I need to combine the contents of three different fields into a single
> field. I understand how to perform an update on a field with the contents
> of another field via a query like:
> UPDATE dice_data SET dice_new_phone = dice_prefix
>
> I need to update this field with a concatenation of three fields actually.
> What I am ignorant of is how to perform such an update. WOuld someone
> kindly guide me in how to perform such an update?
>
> Thanks in advance8-)
>
> Bill Stotts
>
> ps-please reply to me directly as well as the mailing list.
>
> **************************************************************************
> Bill Stotts | Voice: 860-616-7535
> wstotts(at)sonitrol(dot)net | Fax: 860-616-7589
> Sonitrol Communications Corp. |
> |
> _SONITROL_ Expect the best... | Where do you want to GO tomorrow?
> **************************************************************************

--
Ross J. Reedstrom, Ph.D., <reedstrm(at)rice(dot)edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St., Houston, TX 77005

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Hoffmann 1999-02-22 18:40:01 Re: [GENERAL] combining contents of two fields into a new field?
Previous Message Julian Scarfe 1999-02-22 18:14:12 Re: [GENERAL] GIS/GPS Experiences with pgsql?