Re: Group and count at the same time?

From: Date: Thu, 15 Aug 2002 15:26:41 +0000
Subject: Re: Group and count at the same time?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-112775@lists.php.net to get a copy of this message
On Thursday 15 August 2002 23:19, Jeff Lewis wrote: > I am using PHP to maintain a catalog of music and have been just fine with > it but have run into one thing i want to do and need some advice. > > The format of the data is like so: > > upc|genre|distributor|details Where is this info coming from? > What I want to do is grab a "summary". So it would end up printing out: > > rock (43) > country (41) > > and so on. Is this possible to do with one query or will I need to do it > with more? So I want to count the number of each genre and provide a count > for each. If it's from a database then you really should be asking on the php-db list. Something like: select genre, count('genre') from catalog group by genre should work.

« previous php.general (#112775) next »