php-db | 2001072
Date: 07/23/01
- Next message: leo g. divinagracia iii: "Re: [PHP-DB] config php w/ mysql"
- Previous message: Shahmat Dahlan: "Re: [PHP-DB] Access counter"
- In reply to: Mike Gifford: "[PHP-DB] Counting Number of Instances in a One2Many Relationships"
- Next in thread: Mike Gifford: "Re: [PHP-DB] Counting Number of Instances in a One2Many Relationships"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
on 7/23/01 6:53 PM, Mike Gifford at mike <email protected> wrote:
> I'd like a simple query to determine how MANY books in a database are released
> by A publisher. This shouldn't be a big deal, but I've looked at a number of
> solutions and am coming up short. MySQL is being accessed via phplib, but I'm
> sure that it's just how I'm expressing the general MySQL query.
Maybe I'm not quite getting it, but how about:
SELECT COUNT(bibID) FROM bookDB WHERE publisherID='$your_publisher_id';
> The bookID & publisherID are both listed in the bookDB. I just want a query
> which will go through the database and return the publisherID and a count of
> the number of books.
You can do a group by to get them all at once:
SELECT COUNT(*) AS book_count, publisherID FROM bookDB GROUP BY publisherID;
Then use your favorite mysql_fetch_*** and access them.
Hope that helps.
Sincerely,
Paul Burney
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Paul Burney
Webmaster && Open Source Developer
UCLA -> GSE&IS -> ETU
(310) 825-8365
<webmaster <email protected>>
<http://www.gseis.ucla.edu/>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- 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>
- Next message: leo g. divinagracia iii: "Re: [PHP-DB] config php w/ mysql"
- Previous message: Shahmat Dahlan: "Re: [PHP-DB] Access counter"
- In reply to: Mike Gifford: "[PHP-DB] Counting Number of Instances in a One2Many Relationships"
- Next in thread: Mike Gifford: "Re: [PHP-DB] Counting Number of Instances in a One2Many Relationships"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

