hmoner
Programmer
- Mar 3, 2005
- 7
Hi guys
I'm not having a nice time trying to make this query work
I have 2 tables
category
product
I want to list the following way
CATEGORY.NAME | CATEGORY.DESC | PRODUCT_COUNT
The following query works, but it doesn't list the categories that doesn't have products added. I'd like (if possible) to show "0" in PRODUCT_COUNT column, when the category doesn't have products added.
; ==========
SELECT category.id, COUNT(product.fk_category) AS product_count, category.name, category.description FROM product, category WHERE category.id = product.fk_category
GROUP BY product.fk_category
ORDER BY category.name ASC
; ==========
Thanks a lot in advance...
I'm not having a nice time trying to make this query work
I have 2 tables
category
product
I want to list the following way
CATEGORY.NAME | CATEGORY.DESC | PRODUCT_COUNT
The following query works, but it doesn't list the categories that doesn't have products added. I'd like (if possible) to show "0" in PRODUCT_COUNT column, when the category doesn't have products added.
; ==========
SELECT category.id, COUNT(product.fk_category) AS product_count, category.name, category.description FROM product, category WHERE category.id = product.fk_category
GROUP BY product.fk_category
ORDER BY category.name ASC
; ==========
Thanks a lot in advance...