pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedResp: [SQL] Concatenation in selects
2+ messages / 2 participants
[nested] [flat]
* Resp: [SQL] Concatenation in selects
@ 1998-09-03 12:17 Fidelis Assis <fidelis@embratel.com.br>
0 siblings, 0 replies; 2+ messages in thread
From: Fidelis Assis @ 1998-09-03 12:17 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
>
>
>
>
>
Hi,
Try
select first_name || (' ' || last_name) as full_name from ...
if you have problems converting types to the ones expected by
the operator "||", try this one
select ltrim(first_name) || (' ' || ltrim(last_name)) as full_name from
...
where "ltrim" is used only to convert both, first_time and
last_time, to text. I wish I could convert among string types
(bpchar, varchar and text) without any tricks, but it seems this
is not implemented yet.
Fidelis Assis
MCI-Embratel - Rio de Janeiro
PS.:
1- The psql command "\do" will show the list of built-in operators
and "\df" will show the functions;
2- I use 6.3.2 with all patches applied and the OS is AIX 3.2.5
^ permalink raw reply [nested|flat] 2+ messages in thread
* RE: Resp: [SQL] Concatenation in selects
@ 1998-09-03 18:45 Jackson, DeJuan <djackson@cpsgroup.com>
0 siblings, 0 replies; 2+ messages in thread
From: Jackson, DeJuan @ 1998-09-03 18:45 UTC (permalink / raw)
To: Fidelis Assis <fidelis@embratel.com.br>; owner-pgsql-sql@hub.org; pgsql-sql
> select ltrim(first_name) || (' ' || ltrim(last_name)) as full_name
> from
> ...
>
> where "ltrim" is used only to convert both, first_time and
> last_time, to text. I wish I could convert among string types
> (bpchar, varchar and text) without any tricks, but it seems this
> is not implemented yet.
>
Ever tried the cast() function?
-DEJ
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~1998-09-03 18:45 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1998-09-03 12:17 Resp: [SQL] Concatenation in selects Fidelis Assis <fidelis@embratel.com.br>
1998-09-03 18:45 RE: Resp: [SQL] Concatenation in selects Jackson, DeJuan <djackson@cpsgroup.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