开发者

SQL Query to Concat output

I have an addi开发者_Python百科tion SQL question, hopefully someone here can give me a hand.

I have the following mysql table:

ID  Type     Result
1   vinyl    blue, red, green
1   leather  purple, orange
2   leather  yellow

and i am seeking the following output:

ID Row One                 Row Two
1  vinyl blue, red, green  leather purple, orange
2  leather yellow

the thing is... type is not static... there are many different types and not all of them have the same ones. They need to follow in order.


Please post a show create table of your table. It's not clear what you mean in fact.

Maybe what you need is GROUP_CONCAT after all:

mysql> select ID, GROUP_CONCAT(type,' ',result) from test;

Let us know.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜