pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedConcatenation in selects
4+ messages / 3 participants
[nested] [flat]
* Concatenation in selects
@ 1998-09-03 13:22 James Olin Oden <joden@lee.k12.nc.us>
1998-09-03 14:16 ` Re: [SQL] Concatenation in selects James Olin Oden <joden@lee.k12.nc.us>
0 siblings, 1 reply; 4+ messages in thread
From: James Olin Oden @ 1998-09-03 13:22 UTC (permalink / raw)
To: pgsql-sql
I know it can be done, but I cannot seem to figure out how to output to
fields concatenated together in a select. For instance, I have a table
with first_name and last_name as fields (among others). I would like
display first_name and last_name as one field. I want to do something
like:
name=first_name + " " + last_name
but of course within an SQL select statement. Thanks...james
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] Concatenation in selects
1998-09-03 13:22 Concatenation in selects James Olin Oden <joden@lee.k12.nc.us>
@ 1998-09-03 14:16 ` James Olin Oden <joden@lee.k12.nc.us>
1998-09-03 19:33 ` Re: [SQL] Concatenation in selects Leslie Mikesell <les@Mcs.Net>
0 siblings, 1 reply; 4+ messages in thread
From: James Olin Oden @ 1998-09-03 14:16 UTC (permalink / raw)
To: pgsql-sql
> I know it can be done, but I cannot seem to figure out how to output to
> fields concatenated together in a select. For instance, I have a table
> with first_name and last_name as fields (among others). I would like
> display first_name and last_name as one field. I want to do something
> like:
>
> name=first_name + " " + last_name
>
> but of course within an SQL select statement. Thanks...james
Sorry, I finally found it in the hackers mailing list. The answer is:
select textcat(textcat(first_name, ' '),last_name) from users;
I just couldn't seem to find that documented, I am sure it is though.
Thanks...james
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] Concatenation in selects
1998-09-03 13:22 Concatenation in selects James Olin Oden <joden@lee.k12.nc.us>
1998-09-03 14:16 ` Re: [SQL] Concatenation in selects James Olin Oden <joden@lee.k12.nc.us>
@ 1998-09-03 19:33 ` Leslie Mikesell <les@Mcs.Net>
1998-09-04 01:04 ` Re: [SQL] Concatenation in selects Bruce Momjian <maillist@candle.pha.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Leslie Mikesell @ 1998-09-03 19:33 UTC (permalink / raw)
To: joden@lee.k12.nc.us; +Cc: pgsql-sql
According to James Olin Oden:
>
> > I know it can be done, but I cannot seem to figure out how to output to
> > fields concatenated together in a select. For instance, I have a table
> > with first_name and last_name as fields (among others). I would like
> > display first_name and last_name as one field. I want to do something
> > like:
> >
> > name=first_name + " " + last_name
> >
> > but of course within an SQL select statement. Thanks...james
>
> Sorry, I finally found it in the hackers mailing list. The answer is:
>
> select textcat(textcat(first_name, ' '),last_name) from users;
>
> I just couldn't seem to find that documented, I am sure it is though.
> Thanks...james
You should also be able to use the SQL concatenation operator '||'. It
doesn't seem to be able to understand more than 2 things at once so
you have to use parens for grouping. I don't know if that is an SQL
requirement or a postgresql limitation.
select (first_name || ' ') || last_name as full_name from users;
Les Mikesell
les@mcs.com
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] Concatenation in selects
1998-09-03 13:22 Concatenation in selects James Olin Oden <joden@lee.k12.nc.us>
1998-09-03 14:16 ` Re: [SQL] Concatenation in selects James Olin Oden <joden@lee.k12.nc.us>
1998-09-03 19:33 ` Re: [SQL] Concatenation in selects Leslie Mikesell <les@Mcs.Net>
@ 1998-09-04 01:04 ` Bruce Momjian <maillist@candle.pha.pa.us>
0 siblings, 0 replies; 4+ messages in thread
From: Bruce Momjian @ 1998-09-04 01:04 UTC (permalink / raw)
To: les@Mcs.Net; +Cc: joden@Lee.k12.nc.us; pgsql-sql
> You should also be able to use the SQL concatenation operator '||'. It
> doesn't seem to be able to understand more than 2 things at once so
> you have to use parens for grouping. I don't know if that is an SQL
> requirement or a postgresql limitation.
>
> select (first_name || ' ') || last_name as full_name from users;
Yes, that is in the 6.4 bugs list, and if it is not fixed, will be added
to the TODO list.
--
Bruce Momjian | 830 Blythe Avenue
maillist@candle.pha.pa.us | Drexel Hill, Pennsylvania 19026
+ If your life is a hard drive, | (610) 353-9879(w)
+ Christ can be your backup. | (610) 853-3000(h)
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~1998-09-04 01:04 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1998-09-03 13:22 Concatenation in selects James Olin Oden <joden@lee.k12.nc.us>
1998-09-03 14:16 ` James Olin Oden <joden@lee.k12.nc.us>
1998-09-03 19:33 ` Leslie Mikesell <les@Mcs.Net>
1998-09-04 01:04 ` Bruce Momjian <maillist@candle.pha.pa.us>
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