I have 2 tables: products & category
I’m trying to write the sql to count the number of products per category. So far I have this:
SELECT `name`, count(*) as `size`
FROM products
INNER JOIN category ON category.`id` = products.`categoryID`
GROUP BY category.`name`
This will return me a list of each category name and the number of products for that category. However it doesn’t list categories that have 0 products. How do I solve this?
Use a right join.