1

I have a table with 4 columns (product_image_id, product_id, image, sort_order) some of the rows are having the same product_id value but with different image values, I need to move the values from image column that have duplicate product_ids to new columns called image2, image3, image4, image5.

Any help is greatly appreciated.

Schwann
  • 167
  • 1
  • 1
  • 13
  • 2
    http://stackoverflow.com/questions/6605604/mysql-pivot-query-results-with-group-by – Donal Mar 03 '15 at 18:57
  • Are you sure? A better way would be to create an image table and set up a one to many relationship. – Dan Mar 03 '15 at 18:58
  • @Donal Thank you, but the issue with that question is I have so many different product_is and that answer cannot hardcode it in code, I cannot enter every product_id manually, I need a code to find duplicates and move them – Schwann Mar 03 '15 at 19:00
  • @dan08 I would need to export this to CSV so I will have to have them in one column with same product_ids but adding extra images to new columns – Schwann Mar 03 '15 at 19:01

0 Answers0