RE: [PHP-DB] Counting Number of Instances in a One2Many Relationships

From: Date: Tue, 24 Jul 2001 14:50:41 +0000
Subject: RE: [PHP-DB] Counting Number of Instances in a One2Many Relationships
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-10710@lists.php.net to get a copy of this message
<snip> > I'd like a simple query to determine how MANY books in a > database are released by A publisher. [...] > The relevant table's here: > Suggestions are appreciated! SELECT publisherID,count(*) FROM WLPbib GROUP BY publisherID; </snip> That query is only acceptable if you want a list of all the publishers and the books each of them produced. If you only want the results for one publisher SELECT count(*) FROM WLPbib WHERE publisherID = '$idtoquery' should be more than acceptable Either way you may want to consider indexing this table if you have a fairly large number of records or will be doing a fair number of these queries on a regular basis Sincerely, Craig Vincent

« previous php.db (#10710) next »