Justtechjobs.com Find a programming school near you






Online Campus Both


php-db | 2001072

RE: [PHP-DB] Counting Number of Instances in a One2Many Relationships From: Craig Vincent (2bunnyhop <email protected>)
Date: 07/24/01

<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

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>