Re: Concatenating strings - Mailing list pgsql-novice

From Josh Berkus
Subject Re: Concatenating strings
Date
Msg-id web-490614@davinci.ethosmedia.com
Whole thread Raw
In response to Concatenating strings  ("Fredrik Thunberg" <fredrik@datessa.se>)
List pgsql-novice
Frederick,

> How do you add two strings in sql?

You use the ANSI SQL 92 standard concatination operator, ||

e.g. first_name || ' ' || last_name

> I have a name field in one of my tables and all the names are in
> uppercase
> (like "FREDRIK").
> I want to get the names in the usual format (First letter
> capitalized)
> "Fredrik". How
> do I do that?

Well, the good news is that someone has already written a function to do
what you want in one operation.  see:
http://www.postgresql.org/idocs/index.php?functions-string.html

Ah, a former MS SQL Server user.  Transact-SQL uses quite a few bits of
syntax which are *not* ANSI SQL 92 standard; the use of "+" for
concatination is one of them.  It would pay for you to pick up an
introductory PostgreSQL book just to get a handle on the differences
(also, training in real SQL 92 syntax will help you with other
databases, such as Oracle or FrontBase).

-Josh Berkus

______AGLIO DATABASE SOLUTIONS___________________________
                                       Josh Berkus
  Complete information technology      josh@agliodbs.com
   and data management solutions       (415) 565-7293
  for law firms, small businesses        fax 621-2533
    and non-profit organizations.      San Francisco

Attachment

pgsql-novice by date:

Previous
From: Medve Gábor
Date:
Subject: Performance question (PostgreSQL 7.1.3)
Next
From: "Travis Hoyt"
Date:
Subject: [Fwd: views, with check option]