[Wolves] sql query ;-)

sparkes sparkes at westmids.biz
Mon Jun 21 22:48:34 BST 2004


mysql 3.* so none of your fancy sub selects or transactions and the like
Kat ;-)

I have a query that gets the categories from the database with a count of
how  many products are in the product table.  What I want is the query to
show those categories that have zero items as well.

the current query is

"select count(*) as count, Category.CatID, Category.name from product left
join Category on product.CatID = Category.CatID group by Category.CatID
order by count desc"

probably back to front but it almost works.  I just can't get it to show
the categories that have zero products associated with them at the tail
end.  Good enough for the client side of the app where zero entry
categories shouldn't be shown but pants on the admin side where they might
want to add stuff to a category.

Bloody SQL what's wrong with reinventing the wheel in C everytime? ;-)

sparkes



More information about the Wolves mailing list