Re: Concatenating strings

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: Concatenating strings
Дата
Msg-id web-490614@davinci.ethosmedia.com
обсуждение исходный текст
Ответ на Concatenating strings  ("Fredrik Thunberg" <fredrik@datessa.se>)
Список 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

Вложения

В списке pgsql-novice по дате отправления:

Предыдущее
От: Medve Gábor
Дата:
Сообщение: Performance question (PostgreSQL 7.1.3)
Следующее
От: "Travis Hoyt"
Дата:
Сообщение: [Fwd: views, with check option]