Re: a Count() ?

From: Date: Sat, 16 Mar 2002 11:31:32 +0000
Subject: Re: a Count() ?
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-17708@lists.php.net to get a copy of this message
select cat_id, count(prod_id) from some_table order by cat_id; Best regards, Andrey Hristov ----- Original Message ----- From: "Dave Carrera" <dave@davecarrera.com> To: <php-db@lists.php.net> Sent: Saturday, March 16, 2002 12:46 PM Subject: [PHP-DB] a Count() ? > Hi All > > I am trying to count how many product names in my db have the same > category id and then show it ie: > > Catid 1 Product 1 > Catid 1 Product 2 > Catid 2 Product 3 > Catid 3 Product 4 > Catid 3 Product 5 > > Result would be > > Catid1 has 2 products > Catid2 has 1 products > Catid3 has 2 products > > I think it has something to do with the GROUP command but the mysql doc > dose not make it clear how to achive this task. > > Code examples, pointers to web resources or any info thankfully > received. > > Thank you in advance > > > Dave Carrera > Php Developer > http://davecarrera.freelancers.net > http://www.davecarrera.com > > >

« previous php.db (#17708) next »