[Wolves] sql query ;-)
Jon Farmer
jon at viperdude.org
Tue Jun 22 09:17:13 BST 2004
On Mon, June 21, 2004 10:37 pm, sparkes said:
> mysql 3.* so none of your fancy sub selects or transactions and the like
> Kat ;-)
> 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"
You are using the wrong type of join, you need a right join not a left join
select c.name as Category, count(p.CatID) as CountOfProducts from product
as p right join Category as c on p.CatID = c.CatID group by c.name order
by CountOfProduct asc;
regards
Jon
--
Jon Farmer
Telford, Shropshire, UK
http://www.viperdude.org
More information about the Wolves
mailing list