note 11895 deleted from function.mysql-result by didou
| From: | didou@php.net | Date: | Wed, 09 Jul 2003 15:22:03 +0000 |
| Subject: | note 11895 deleted from function.mysql-result by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-51792@lists.php.net to get a copy of this message | ||
Note Submitter: alec@brainpod.com
----
"select count(*) from users" will return a table with one row and one field whith the
count of how many results the last select would have returned.
"select * from users" will return ALL the data from the rows that match this.
So using the second query followed by $mysql_num_rows to retrieve a count of rows is inefficient if
you don't need the actual data but just the count. Keep this in mind. Following is an example
of using the count function practically with MySQL:
select MONTHNAME(orderdate) as month, DAYOFMONTH(orderdate) as day, count(*) as volume from orders
group by month,day;
might produce something like this for a quick tally of sales:
+-------+------+--------+
| month | day | volume |
+-------+------+--------+
| March | 7 | 4 |
| March | 8 | 13 |
| March | 9 | 10 |
| March | 10 | 4 |
| March | 11 | 1 |
| March | 12 | 1 |
+-------+------+--------+
6 rows in set (0.01 sec)
Alec Effrat
alec@brainpod.com