You are here: Re: Count Number of Items in each Category « PHP Programming Language « IT news, forums, messages
Re: Count Number of Items in each Category

Posted by Jerry Stuckle on 04/10/06 07:13

Barkster wrote:
> I'm trying to list my categories and how many items are in each
> category. I'm not much on sub queries. How can I combine these two
> items. I'd like to display the category and the corresponding number of
> items in each
>
> Cats:
> Select
> Category.CategoryID,
> Category.Category,
> Category.Sorting
> From
> Category
> Order By
> Category.Sorting Desc
>
> Items:
> Select Count(Listings.CategoryID)
> From
> Listings
> Group By
> Listings.CategoryID
>
> I've tried the following but can't get it to work:
>
> Select
> Category.CategoryID,
> Category.Category,
> Category.Sorting,
> (Select Count(Listings.CategoryID)
> From
> Listings WHERE Listings.CategoryID = Category.CategoryID) AS cnt
> From
> Category
> Order By
> Category.Sorting Desc
>


It depends on your database - both which database and what version you're using.

Since this isn't a PHP question, try asking in a newsgroup for your database.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация