Re: Stupid question: concatenating strings
| От | Thomas Good |
|---|---|
| Тема | Re: Stupid question: concatenating strings |
| Дата | |
| Msg-id | Pine.LNX.3.96.1001018133756.19538A-100000@q8.nrnet.org обсуждение исходный текст |
| Ответ на | Re: Stupid question: concatenating strings (Tom Lane <tgl@sss.pgh.pa.us>) |
| Ответы |
Re: Stupid question: concatenating strings
|
| Список | 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
--------------------------------------------------------------------
В списке pgsql-novice по дате отправления: