Обсуждение: Combining output of several fields in SQL query
Hi all, This is a plain simple sql question appologies for posting it here. Am looking for a way of combining values from several fields(and introducting value separators). select field2+"_"+field1 from tableA; I've tried select field2||'_'||field1 from tableA; I get "1" as the result(which is not what I want). Allan. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
On 9/12/06, Allan Kamau <kamauallan@yahoo.com> wrote:
What does tableA look like (DDL and the data)?
==================================================================
Aaron Bono
Aranya Software Technologies, Inc.
http://www.aranya.com
http://codeelixir.com
==================================================================
Hi all,
This is a plain simple sql question appologies for
posting it here.
Am looking for a way of combining values from several
fields(and introducting value separators).
select field2+"_"+field1 from tableA;
I've tried
select field2||'_'||field1 from tableA;
I get "1" as the result(which is not what I want).
==================================================================
Aaron Bono
Aranya Software Technologies, Inc.
http://www.aranya.com
http://codeelixir.com
==================================================================
create table tableA( s_l_p_p_v_i text not null, field1 text not null, field2 text not null, primary key(field1,field2)); s_l_p_p_v_i field1 field1 abc 2 1 xyz 2 4 klm 2 3 --- Aaron Bono <postgresql@aranya.com> wrote: > On 9/12/06, Allan Kamau <kamauallan@yahoo.com> > wrote: > > > > Hi all, > > This is a plain simple sql question appologies for > > posting it here. > > > > Am looking for a way of combining values from > several > > fields(and introducting value separators). > > > > select field2+"_"+field1 from tableA; > > > > I've tried > > select field2||'_'||field1 from tableA; > > I get "1" as the result(which is not what I want). > > > > What does tableA look like (DDL and the data)? > > ================================================================== > Aaron Bono > Aranya Software Technologies, Inc. > http://www.aranya.com > http://codeelixir.com > ================================================================== > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
On 9/12/06, Allan Kamau <kamauallan@yahoo.com> wrote:
Your initial query:
select field2||'_'||field1 from tableA;
works perfectly for me:
?column?
4_2
1_2
3_2
Are you sure you are not getting the correct results?
==================================================================
Aaron Bono
Aranya Software Technologies, Inc.
http://www.aranya.com
http://codeelixir.com
==================================================================
create table tableA(
s_l_p_p_v_i text not null,
field1 text not null,
field2 text not null,
primary key(field1,field2));
s_l_p_p_v_i field1 field1
abc 2 1
xyz 2 4
klm 2 3
Your initial query:
select field2||'_'||field1 from tableA;
works perfectly for me:
?column?
4_2
1_2
3_2
Are you sure you are not getting the correct results?
==================================================================
Aaron Bono
Aranya Software Technologies, Inc.
http://www.aranya.com
http://codeelixir.com
==================================================================