pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedConcat two fields into one at runtime
5+ messages / 5 participants
[nested] [flat]
* Concat two fields into one at runtime
@ 2006-06-08 15:50 George Handin <postgresql@dafunks.com>
0 siblings, 4 replies; 5+ messages in thread
From: George Handin @ 2006-06-08 15:50 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Concat two fields into one at runtime
@ 2006-06-08 15:53 Aaron Bono <postgresql@aranya.com>
parent: George Handin <postgresql@dafunks.com>
3 siblings, 0 replies; 5+ messages in thread
From: Aaron Bono @ 2006-06-08 15:53 UTC (permalink / raw)
To: George Handin <postgresql@dafunks.com>; +Cc: pgsql-sql
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
>
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Concat two fields into one at runtime
@ 2006-06-08 15:54 Kenneth B Hill <ken@scottshill.com>
parent: George Handin <postgresql@dafunks.com>
3 siblings, 0 replies; 5+ messages in thread
From: Kenneth B Hill @ 2006-06-08 15:54 UTC (permalink / raw)
To: George Handin <postgresql@dafunks.com>; +Cc: pgsql-sql
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
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Concat two fields into one at runtime
@ 2006-06-08 15:54 Bricklen Anderson <banderson@presinet.com>
parent: George Handin <postgresql@dafunks.com>
3 siblings, 0 replies; 5+ messages in thread
From: Bricklen Anderson @ 2006-06-08 15:54 UTC (permalink / raw)
To: George Handin <postgresql@dafunks.com>; +Cc: pgsql-sql
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
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Concat two fields into one at runtime
@ 2006-06-08 15:56 Oisin Glynn <me@oisinglynn.com>
parent: George Handin <postgresql@dafunks.com>
3 siblings, 0 replies; 5+ messages in thread
From: Oisin Glynn @ 2006-06-08 15:56 UTC (permalink / raw)
To: George Handin <postgresql@dafunks.com>; +Cc: pgsql-sql
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
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2006-06-08 15:56 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-06-08 15:50 Concat two fields into one at runtime George Handin <postgresql@dafunks.com>
2006-06-08 15:53 ` Aaron Bono <postgresql@aranya.com>
2006-06-08 15:54 ` Kenneth B Hill <ken@scottshill.com>
2006-06-08 15:54 ` Bricklen Anderson <banderson@presinet.com>
2006-06-08 15:56 ` Oisin Glynn <me@oisinglynn.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox