how to join multiple columns in a table

Hi,Suppose I have the following table and values:ID Lname Fname Mname---------------------------------------------------01 EGF ABC KU02 UJH HIJ PR03 TRF GRD CHI want to create another table which will be having the followingvalues:ID NAME---------------------01 ABC KU EGF02 HIJ PR UJH03 GRD CH TRFCan anyone let me know how to do that ?

Well depends on what the types are. Just considering strings here:

q)tbl:( ID:(“01”;“02”;“03”); Lname:(“EGF”;“UJH”;“TRF”); Fname:(“ABC”;“HIJ”;“GRD”); Mname:(“KU”;“PR”;“CH”))
q)show tbl
ID?? Lname Fname Mname

“01” “EGF” “ABC” “KU”
“02” “UJH” “HIJ” “PR”
“03” “TRF” “GRD” “CH”

But something like this would do the trick. Should be easy to tweak if you’re not using strings.

q)show select ID, NAME:{x," “,y,” ",z}'[Fname;Mname;Lname] from tbl
ID?? NAME

“01” “ABC KU EGF”
“02” “HIJ PR UJH”
“03” “GRD CH TRF”

Here Data types are Symbols

2009/10/21 Daniel Br?ndstr?m <daniel.brandstrom@gmail.com>

Well depends on what the types are. Just considering strings here:

q)tbl:( ID:(“01”;“02”;“03”); Lname:(“EGF”;“UJH”;“TRF”); Fname:(“ABC”;“HIJ”;“GRD”); Mname:(“KU”;“PR”;“CH”))
q)show tbl

ID?? Lname Fname Mname

“01” “EGF” “ABC” “KU”
“02” “UJH” “HIJ” “PR”
“03” “TRF” “GRD” “CH”

But something like this would do the trick. Should be easy to tweak if you’re not using strings.

q)show select ID, NAME:{x," “,y,” ",z}'[Fname;Mname;Lname] from tbl

ID?? NAME

“01” “ABC KU EGF”
“02” “HIJ PR UJH”
“03” “GRD CH TRF”

Thanks

2009/10/21 Daniel Br?ndstr?m <daniel.brandstrom@gmail.com>

Well depends on what the types are. Just considering strings here:

q)tbl:( ID:(“01”;“02”;“03”); Lname:(“EGF”;“UJH”;“TRF”); Fname:(“ABC”;“HIJ”;“GRD”); Mname:(“KU”;“PR”;“CH”))
q)show tbl

ID?? Lname Fname Mname

“01” “EGF” “ABC” “KU”
“02” “UJH” “HIJ” “PR”
“03” “TRF” “GRD” “CH”

But something like this would do the trick. Should be easy to tweak if you’re not using strings.

q)show select ID, NAME:{x," “,y,” ",z}'[Fname;Mname;Lname] from tbl

ID?? NAME

“01” “ABC KU EGF”
“02” “HIJ PR UJH”
“03” “GRD CH TRF”

if you have symbols

q)select ID, NAME:flip(Fname;Mname;Lname) from `$tbl

ID NAME      


01 ABC KU EGF

02 HIJ PR UJH

03 GRD CH TRF

Regards,

  Attila

Thanks :-)

Hi,

q)tbl:(wid:int$();countrycode:symbol$();cityareacode:symbol$();number:symbol$())
q)insert[tbl;(1001;1;201;8760987)]
q)insert[tbl;(1002;1;201;1234123)]
q)insert[tbl;(1003;1;877;9876765)]
q)insert[tbl;(1004;21;201;9875252)]
q)insert[tbl;(1005;41;877;5643533)]

q)select wid,phoneno:{(`$ string “+”,x,“-”,y,“-”,z)}'[countrycode;cityareacode;number] from tbl
wid?? phoneno

1001 + 1? - 201 - 8760987
1002 + 1? - 201 - 1234123
1003 + 1? - 877 - 9876765
1004 + 21 - 201 - 9875252
1005 + 41 - 877 - 5643533

But I want the result should be like below:

wid??? phoneno

1001?? +1-201-8760987
1002?? +1-201-1234123
1003?? +1-877-9876765
1004?? +21-201- 9875252
1005?? +91-877- 5643533

(Without spaces for phoneno column)

can anyone know how to get it?

Thanks in adv
Jyoti

q)select wid,phoneno:{(`$“+”,string,“-”,string[y],“-”,string[z])}'[countrycod
e;cityareacode;number] from tbl
wid? phoneno

1001 +1-201-8760987
1002 +1-201-1234123
1003 +1-877-9876765
1004 +21-201-9875252
1005 +41-877-5643533
?Attila

Thanks a lot