是否可以选择一个int作为JOINed String?

时间:2012-01-15 22:12:40

标签: mysql

我很好奇是否有可能选择,因为一个字段是几个整数id的JOIN ...

table foo
1 | a
2 | b
3 | c

然后是伪代码:

select CONCAT_AS_STRING( (select id from foo), ",");  //the "," would be the token that it would JOIN on

所以结果会是 “1,2,3”

MySQL有这样的功能吗?

1 个答案:

答案 0 :(得分:3)

尝试GROUP_CONCAT:

SELECT GROUP_CONCAT(id SEPARATOR',')FROM foo;