What's the best way to combine rows with similar values into a single row while still keeping a row data. I need to get quantities from a database with different window_id but with the same meal_id. I would like them to be in the same object/same row so that I can map through them in a table. What's the best way to do this? Thank you
Starting Data
--------------------------------------------
window_id | meal_id | meal_name | qty
--------------------------------------------
1 1 Salad 4
2 1 Salad 6
3 1 Salad 7
1 2 Pork 4
2 2 Pork 9
3 2 Pork 10
**OR** in Javascript Object
{
windowId: 1
mealId: 1,
mealName: "Salad",
qty: 4
},
{
windowId: 2
mealId: 1,
mealName: "Salad",
qty: 6
},
{
windowId: 3
mealId: 1,
mealName: "Salad",
qty: 7
}
Desired Result
--------------------------------------------------------------
meal_id | meal_name | qty1 | qty2 | qty3...
--------------------------------------------------------------
1 Salad 4 6 7
2 Pork 4 9 10
**OR** in Javascript Object
{
mealId: 1,
mealName: "Salad",
qty1: 4,
qty2: 6,
qty3: 7
}