Board index » delphi » sql 'select field1||field2 as newField' question

sql 'select field1||field2 as newField' question

Using the sql 'Select field1||field2 as newfield from someTable' gives
me newField = value1+value2. (example if field1 ='a'and field2='b'
result = 'ab')

I would like to get newField = value1+' - '+value2; (I want newField =
'a - b').

How do I code this into the sql statement??

 

Re:sql 'select field1||field2 as newField' question


Quote
Joe Nodeland wrote:

> Using the sql 'Select field1||field2 as newfield from someTable' gives
> me newField = value1+value2. (example if field1 ='a'and field2='b'
> result = 'ab')

> I would like to get newField = value1+' - '+value2; (I want newField =
> 'a - b').

> How do I code this into the sql statement??

It's OK to use string constants in the select so -
'Select field1||" - "||field2 as newfield from someTable'
would do it.

Re:sql 'select field1||field2 as newField' question


Quote
Joe Nodeland wrote:

> Using the sql 'Select field1||field2 as newfield from someTable' gives
> me newField = value1+value2. (example if field1 ='a'and field2='b'
> result = 'ab')

> I would like to get newField = value1+' - '+value2; (I want newField =
> 'a - b').

> How do I code this into the sql statement??

Select value1||' - '||value2 as newfield ...

--
-----------------------------------------
Software Services - Making Windows Scream
http://www.invsn.com/softserv/
bry...@thevision.net
-----------------------------------------

Re:sql 'select field1||field2 as newField' question


JN>Using the sql 'Select field1||field2 as newfield from someTable' gives
  >me newField = value1+value2. (example if field1 ='a'and field2='b'
  >result = 'ab')

JN>I would like to get newField = value1+' - '+value2; (I want newField =
  >'a - b').

It's so easy:
   'Select field || " - " || field2 as newfield from sometable'

[]s, Shen, james.s...@mandic.com.br, phone: (0)55-(0)11-30647973
---
 * QMPro 1.53 * Delphi 2 & 1 - Curso Completo de Prg & BD C/S

Other Threads