0

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.

2
  • Unfortunately, this question isn't very coherent. For instance what does "not all of them have the ones" mean? Commented May 20, 2010 at 19:21
  • I apologize, let me try to clarify. There is a column called type in the original table; it can have a wide range of values. Not all ID's have the same types. For each ID in the table it needs to be able to create a new column for each type and concat the result and type together in there. I hope this makes atleast some sense. Commented May 20, 2010 at 19:24

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.