MySQL : Multiple row as comma separated single row

Use GROUP_CONCAT FUNCTION

http://dev.mysql.com/tech-resources/articles/4.1/grab-bag.html

 SELEct m.meal_Id, 
        GROUP_CONCAT(dish_id) dish_ids, 
        GROUP_CONCAT(dish_name) dish_names
 FROM DISH_HAS_DISHES m JOIN DISH d ON (m.dish_id = d.dish_id)
 GROUP BY meal_Id

Leave a Comment