Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

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


  • From: "Ross J. 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: Mon, 22 Feb 1999 12:23:41 -0600
  • Message-id: <36D1A0AD.5B29F7D5@rice.edu> <text/plain>

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



Home | Main Index | Thread Index

Privacy Policy | About PostgreSQL
Copyright © 1996 – 2012 PostgreSQL Global Development Group