# string concatenation in select phrase

**URL:** <https://forum.kx.com/t/string-concatenation-in-select-phrase/9106>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [October 1, 2014, 2:41am UTC](https://forum.kx.com/t/string-concatenation-in-select-phrase/9106 "2014-10-01T02:41:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![denghao8888](https://avatars.discourse-cdn.com/v4/letter/d/d2c977/32.png) [@denghao8888](https://forum.kx.com/u/denghao8888)\
**Post date:** [October 1, 2014, 2:41am UTC](https://forum.kx.com/t/string-concatenation-in-select-phrase/9106/1 "2014-10-01T02:41:00Z")

</div>

when t : (; a : 1 &nbsp;2 3; b : 4 5 6)

I can use&nbsp;

select a + b from t

but to concatenate string, it’s hard.

Given &nbsp;t : (; a : “abc” ; b : “ABC”),  
how can I concatenate “a” and “A”, “b” and “B” in a select like below?

select a,b from t &nbsp; will not work.

I can define:

q) cat : ,

q) select cat[a;b] from t &nbsp;

b

- 

a

b

c

A

B

C

still not work as expected.&nbsp;

I guess if I can define a cat function that takes character only, it will work.&nbsp;

But I don’t know how to do it.

Any help?

Thanks!

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![rory\_ororke](https://avatars.discourse-cdn.com/v4/letter/r/49beb7/32.png) [@rory\_ororke](https://forum.kx.com/u/rory_ororke)\
**Post date:** [October 1, 2014, 4:42am UTC](https://forum.kx.com/t/string-concatenation-in-select-phrase/9106/2 "2014-10-01T04:42:00Z")

</div>

Hi,  
You need to use join each

q)select (a,'b) from t

b

* * *

“aA”

“bB”

“cC”

Thanks Rory

---

<div class="post-metadata">

**Author:** ![pauljloughran](https://avatars.discourse-cdn.com/v4/letter/p/9e8a1a/32.png) [@pauljloughran](https://forum.kx.com/u/pauljloughran)\
**Post date:** [October 1, 2014, 4:42am UTC](https://forum.kx.com/t/string-concatenation-in-select-phrase/9106/3 "2014-10-01T04:42:00Z")

</div>

Hi,

Is this what you are looking for?

## q)select (a,'b) from t b

"aA"  
"bB"  
"cC"

You should think of a and b as vectors.

Regards,

Paul

---

<div class="post-metadata">

**Author:** ![denghao8888](https://avatars.discourse-cdn.com/v4/letter/d/d2c977/32.png) [@denghao8888](https://forum.kx.com/u/denghao8888)\
**Post date:** [October 1, 2014, 1:41pm UTC](https://forum.kx.com/t/string-concatenation-in-select-phrase/9106/4 "2014-10-01T13:41:00Z")

</div>

Yes exactly,&nbsp;  
thank you both Rory and Paul.

---

<div class="post-metadata">

**Author:** ![charlie1](https://avatars.discourse-cdn.com/v4/letter/c/ec9cab/32.png) [@charlie1](https://forum.kx.com/u/charlie1)\
**Post date:** [October 1, 2014, 1:50pm UTC](https://forum.kx.com/t/string-concatenation-in-select-phrase/9106/5 "2014-10-01T13:50:00Z")

</div>

or

q)(select flip(a;b)from t)~select (a,'b) from t

1b
