combine column?
Posted in 1999
Topics: SQL Development & Query Writing
hi all: is there anyway to combine text fileds in a select statement? say i have a,b as fields in my table, what would be the sql to output one column whose content is the combination of a and b. If the value in field a is "informix", and the value in b is "iscool", I want my output to be "informixiscool". possible? thanks yan
Double pipes are the answer: select a || b from ... column a will be padded to full space if defined as a char(n). I believe it will truncate if defined as a varchar. 7.2+ (maybe before; that's the manual version I have) engines have a trim() expression that can truncate spaces. You SQL syntax manual will have more. Yan Zhu wrote in message <79eude$e8v$1@news.xmission.com>... > > >hi all: > is there anyway to combine text fileds in a select statement? > say i have a,b as fields in my table, what would be the sql to >output one column whose content is the combination of a and b. If the >value in field a is "informix", and the value in b is "iscool", I want >my output to be "informixiscool". possible? > thanks >yan > >
Yes, Use the concatenation operator of two vertical pipes (||) as in select a||b from thetable; Doug Agnew Yan Zhu wrote in message <79eude$e8v$1@news.xmission.com>... > > >hi all: > is there anyway to combine text fileds in a select statement? > say i have a,b as fields in my table, what would be the sql to >output one column whose content is the combination of a and b. If the >value in field a is "informix", and the value in b is "iscool", I want >my output to be "informixiscool". possible? > thanks >yan > >
Try double pipe (for concatenation); e.g. select a||b from table1; KG