Re: Concat two fields into one at runtime

Поиск
Список
Период
Сортировка
Искать

Re: Concat two fields into one at runtime

От:
Kenneth B Hill <ken@scottshill.com>
Дата:
On Thu, 2006-06-08 at 10:50 -0500, George Handin wrote:
> Is there a way using built-in PostgreSQL functions to combine two data 
> fields into a single field at runtime when querying data?
> 
> For example, the query now returns:
> 
> id    first    last
> ---   -------  ----------
> 1     Goerge   Handin
> 2     Joe      Rachin
> 
> I'd like it to return:
> 
> id    name
> ---   -------------------
> 1     George Handin
> 2     Joe Rachin
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings

Try this:

SELECT id, first || || last AS name
FROM table;

-Ken


Concat two fields into one at runtime

От:
George Handin <postgresql@dafunks.com>
Дата:
Is there a way using built-in PostgreSQL functions to combine two data 
fields into a single field at runtime when querying data?

For example, the query now returns:

id    first    last
---   -------  ----------
1     Goerge   Handin
2     Joe      Rachin

I'd like it to return:

id    name
---   -------------------
1     George Handin
2     Joe Rachin

Re: Concat two fields into one at runtime

От:
Bricklen Anderson <banderson@presinet.com>
Дата:
George Handin wrote:
> Is there a way using built-in PostgreSQL functions to combine two data 
> fields into a single field at runtime when querying data?
> 
> For example, the query now returns:
> 
> id    first    last
> ---   -------  ----------
> 1     Goerge   Handin
> 2     Joe      Rachin
> 
> I'd like it to return:
> 
> id    name
> ---   -------------------
> 1     George Handin
> 2     Joe Rachin

select id,first||' '||last from your_table

Re: Concat two fields into one at runtime

От:
Oisin Glynn <me@oisinglynn.com>
Дата:
George Handin wrote:
> Is there a way using built-in PostgreSQL functions to combine two data 
> fields into a single field at runtime when querying data?
>
> For example, the query now returns:
>
> id    first    last
> ---   -------  ----------
> 1     Goerge   Handin
> 2     Joe      Rachin
>
> I'd like it to return:
>
> id    name
> ---   -------------------
> 1     George Handin
> 2     Joe Rachin
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
if you want the 2 fields with a space between them

select first ||' '||last as name from foo;

should do it.

Oisin


Re: Concat two fields into one at runtime

От:
"Aaron Bono" <postgresql@aranya.com>
Дата:
select id, first || ' ' || last
from mytable;

On 6/8/06, George Handin <postgresql@dafunks.com> wrote:
Is there a way using built-in PostgreSQL functions to combine two data
fields into a single field at runtime when querying data?

For example, the query now returns:

id    first    last
---   -------  ----------
1     Goerge   Handin
2     Joe      Rachin

I'd like it to return:

id    name
---   -------------------
1     George Handin
2     Joe Rachin

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings


FAQ