DaveC
DaveC

Reputation: 1047

SQL Query to Concat output

I have an addition 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.

Upvotes: 0

Views: 108

Answers (1)

Xavier Maillard
Xavier Maillard

Reputation: 958

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.

Upvotes: 1

Related Questions