From: Fidelis Assis <fidelis@embratel.com.br>
To: owner-pgsql-sql@hub.org, "pgsql-sql@postgreSQL.org" <pgsql-sql@postgreSQL.org>
Subject: Resp: [SQL] Concatenation in selects
Date: 3 Sep 1998 12:17:43 +0000
Message-ID: <9703171203091998/A00669/SCI02/11C91B110300*@MHS> (raw)
In-Reply-To: <81Sep2.081317edt.35713@gateway.lee.k12.nc.us>
>
>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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: fidelis@embratel.com.br
Subject: Re: Resp: [SQL] Concatenation in selects
In-Reply-To: <9703171203091998/A00669/SCI02/11C91B110300*@MHS>
References: <81Sep2.081317edt.35713@gateway.lee.k12.nc.us> <9703171203091998/A00669/SCI02/11C91B110300*@MHS>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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