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

Ross Reedstrom <reedstrm@rice.edu>

From: "Ross J. Reedstrom" <reedstrm@rice.edu>
To: pgsql-general@postgresql.org
Date: 1999-02-22T18:23:41Z
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@sonitrol.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@rice.edu> 
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St.,  Houston, TX 77005