I am making a shopping cart. Selected items are stored inside a database based on a search query.
How I can add the quantity for rows in case sku, type and color are the same values?
example:
sku type color quantity
---------------------------
1 type1 blue 5
1 type1 blue 2
2 type1 blue 5
1 type1 green 5
my new rows should be:
sku type color quantity
---------------------------
1 type1 blue 7
2 type1 blue 5
1 type1 green 5
Notice the first row quantity is now 7.
How can this be done? I tried GROUP BY, but didn't know how to make it dynamic to match all.