Grouping results in simple but big table

Hi all

I have a table like this

|id | sku | Barcode |

I have 55k+ records

Some skus only have one barcode, some have up to six.

I would like to display a table of all skus with the results of their barcodes after them eg

|id | sku | Barcode1 | Barcode2 | Barcode 3 | Barcode 4 | Barcode 5 | Barcode 6 |

1 a 12345
2 b 123666 123654 123447
3 c 98778

I have tried a GROUP by statement but this does not seem to do what I am after.

I am trying to display this on a page with PHP, but I feel I need to get the query right first. Or should I be looking to get PHP to do the work?


if your database is mysql, you can do this quite easily with the GROUP_CONCAT aggregate function