I'm having some trouble with my shopping cart table. I've created a table that looks like this:
My problem is that I want to be able to select the product id, and the count on how many times this product id is repeated in the table so I can display how many quantities of an item the user has in the cart.
Looking for an output result that looks like this:
| user_id | product_id | num of prodcuts| ----------------------------------------- | 12 | 43 | 3 | | 12 | 51 | 1 | | 21 | 39 | 2 | | 17 | 41 | 1 |
So I want to select product_id
and also count it in a single query and I got no idea of how this is done so I'd really appreciate some help.