Received: from gatekeeper.embratel.com.br (gatekeeper.embratel.com.br [200.255.122.2]) by hub.org (8.8.8/8.7.5) with SMTP id LAA18811 for ; Thu, 3 Sep 1998 11:49:58 -0400 (EDT) Received: by gatekeeper.embratel.com.br; (5.65v3.2/1.3/10May95) id AA10642; Thu, 3 Sep 1998 13:01:51 -0300 X400-Received: by mta ebtrj in /PRMD=EBT/ADMD=EMBRATEL/C=BR/; Relayed; 3 Sep 1998 15:35:11 +0000 X400-Received: by /PRMD=EBT/ADMD=EMBRATEL/C=BR/; Relayed; 3 Sep 1998 12:27:24 +0000 X400-Received: by mta "SCI02.MUAS" in /PRMD=EBT/ADMD=EMBRATEL/C=BR/; Relayed; 3 Sep 1998 12:17:03 +0000 X400-Received: by mta SCI02 in /PRMD=EBT/ADMD=EMBRATEL/C=BR/; Relayed; 3 Sep 1998 12:17:03 +0000 X400-Received: by mta GO686 in /PRMD=EBT/ADMD=EMBRATEL/C=BR/; Relayed; 3 Sep 1998 12:17:43 +0000 Date: 3 Sep 1998 12:17:43 +0000 X400-Originator: fidelis@mailgate.embratel.com.br X400-Mts-Identifier: [/PRMD=EBT/ADMD=EMBRATEL/C=BR/; 9703171203091998/A00669/SCI02] Discarded-X400-Mts-Extensions: (43) (12) (2) (135) (115) (5) (6) (3) From: "Fidelis Assis" (Tel +55 21 519 8408) To: owner-pgsql-sql@hub.org, "pgsql-sql@postgreSQL.org" In-Reply-To: <81Sep2.081317edt.35713@gateway.lee.k12.nc.us> Subject: Resp: [SQL] Concatenation in selects Importance: normal Sensitivity: Company-Confidential Autoforwarded: FALSE Message-Id: <9703171203091998/A00669/SCI02/11C91B110300*@MHS> Original-Encoded-Information-Types: (1) (0) (10021) (7) (1) (0) (6), (1) (0) (10021) (7) (1) (0) (1) Content-Identifier: 11C91B110300 X400-Content-Type: P2-1988 (22) Priority: normal > >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