Re: query and count
| From: | Daniel Barton | Date: | Wed, 09 Jan 2002 20:25:06 +0000 |
| Subject: | Re: query and count | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-15573@lists.php.net to get a copy of this message | ||
Hi,
I hate to simply refer to other sources in a response, but cross-tabulations are a large and
rich subject which are
too large for the time I have to write this email. I would suggest reading this article:
http://www.devshed.com/Server_Side/MySQL/MySQLWiz
which is a pretty good source of information on how to obtain some very useful results from MySQL
tables. Be more than
happy to answer questions on cross-tabs though - it's a very fun way to query.
-db
Barry Rumsey wrote:
> I have two tables, the first one I query like :
>
> $query = "SELECT * FROM xp_topics WHERE artist_count='artist' AND topictext LIKE
> 'B%' ORDER BY artist_count DESC limit 0,5"; $req =
> mysql_query($query);
> $res = mysql_num_rows($req); if ($res == 0) { echo "</p>
> <p><b>Sorry there is no result.</b>";} else { while($row =
> mysql_fetch_array($req))
> { extract($row); echo ("$topictext<br>
> "); } }
>
> The second one I want to do a count for each one that was returned above. eg Billie (2) , Bill
> (4) Bret (1)........
> How would I set up the query to do both?
--
----------
Dan Barton
Terrestrial Program Biologist
Asst. Data Manager
Point Reyes Bird Observatory
http://www.prbo.org
dbarton@prbo.org
dbarton@grayflycatcher.org