Re: Stupid question: concatenating strings

From: Bill Morrow <wmorrow(at)home(dot)com>
To: justinlong(at)strategicnetwork(dot)org
Cc: pgsql-novice(at)hub(dot)org
Subject: Re: Stupid question: concatenating strings
Date: 2000-10-18 17:32:07
Message-ID: 39EDDE97.21B65025@home.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

This does not work either:
select 'a' + 'b';
ERROR: Unable to identify an operator '+' for types
'unknown' and 'unknown'
You will have to retype this query using an explicit
cast

But this does:
select 'a' || 'b';
?column?
----------
ab
(1 row)

Look at the Postgres manual section on String concatenation.

Bill
Justin Long wrote:
>
> I can't figure out how to do this.
>
> I want to do the following
>
> UPDATE newlink SET newfrom = substr(oldfrom,0,1) + '-' + substr(oldfrom,1)
>
> ... I want to do this:
>
> take the following variables
>
> CAFG
> CBTN
> CNPL
> CUSA
>
> and transform it to this:
>
> C-AFG
> C-BTN
> C-NPL
> C-USA
>
> Someone please help me! I've been through the user manual & I can't find out
> how to do it. Pgsql just tells me:
>
> Unable to identify an operator '+' for types 'text' and 'unknown'
> You will have to retype this query using an explicit cast
>
> _________________________________________________________________
> Justin Long Network for Strategic Missions
> 1732 South Park Court Never retreat. Never surrender.
> Chesapeake, VA 23320, USA Never cut a deal with a dragon.
> 757-213-2055, ICQ 83384482 http://www.strategicnetwork.org
> Monday Morning Reality Check: reality-check-subscribe(at)egroups(dot)com

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2000-10-18 17:34:00 Re: problem to compile 7.0.2
Previous Message Justin Long 2000-10-18 17:28:55 Thanks for all the answers!