From: | Thomas Good <tomg(at)q8(dot)nrnet(dot)org> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | justinlong(at)strategicnetwork(dot)org, pgsql-novice(at)hub(dot)org |
Subject: | Re: Stupid question: concatenating strings |
Date: | 2000-10-18 17:46:08 |
Message-ID: | Pine.LNX.3.96.1001018133756.19538A-100000@q8.nrnet.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Wed, 18 Oct 2000, Tom Lane 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)
> The string concatenation operator in SQL is ||, not +.
>
> Also, substr's start-index argument counts from 1 not 0. Otherwise
> you've got the right idea...
>
> regards, tom lane
Tom,
The || operator needs parentheses to concat > 2 items in Pg 6.3.2.
Has this been fixed in subsequent versions?
If not, for Justin - this is what I do to concat more than
two items...
select (staff_fname || staff_lname) || ('-' || staff_ssn)
as "Social Security"
from personnel
where staff_id = 1000;
Cheers,
Tom Good
--------------------------------------------------------------------
SVCMC - Center for Behavioral Health
--------------------------------------------------------------------
Thomas Good tomg@ { admin | q8 } .nrnet.org
IS Coordinator / DBA Phone: 718-354-5528
Fax: 718-354-5056
--------------------------------------------------------------------
Powered by: PostgreSQL s l a c k w a r e FreeBSD:
RDBMS |---------- linux The Power To Serve
--------------------------------------------------------------------
From | Date | Subject | |
---|---|---|---|
Next Message | Beth Gatewood | 2000-10-18 19:51:25 | data dictionary? |
Previous Message | Leandro Fanzone | 2000-10-18 17:42:35 | XML |