开发者

SQL Query to Concat output

开发者 https://www.devze.com 2022-12-31 06:07 出处:网络
I have an addi开发者_Python百科tion SQL question, hopefully someone here can give me a hand. I have the following mysql table:

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

精彩评论

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