Note Submitter: [email]alec@brainpod.com[/email]

----

"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
[email]alec@brainpod.com[/email]