SELECT items.id,
items.category,
COUNT(*)
FROM items
GROUP BY items.id,
items.category

I want to display how many items in each category.
For example,
category 1 - 6
category 2 - 7
category 3 - 4 ...
Please help me! I try this request and show me all the items with category :/
Try this...
SELECT items.category,
COUNT(*) AS Count
FROM items
GROUP BY items.category
Please use 'distinct'
SELECT distinct items.category,
COUNT(*) AS Count
FROM items
GROUP BY items.category
to get the correct count for each unique category
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With