Help with Data

I need help formatting data for cs-cart 1.35 import. Let assume these are product features. The data I have from a vendor has a single color value for each row, and if a product is available in more than one color it has more rows



I have data in a table like

[B]prod_id Color[/B]
1 Blue
1 Red
2 Tan
3 Red
3 Black


And I need it to look like this

[B]prod_id Color[/B]
1 Blue, Red
2 Tan
3 Red, Black




So how can I format the data so that I have one product per row, and with the one or more associated color in a comma separate list in a single field.



Does anyone know how I can create a PHP page to query the database, and dump the data to a format like the one above.



Or is this can be done directly in MySQL that would be great.