View Full Version : how to use SELECT Count
niluj
12-03-2005, 02:29 AM
how to use SELECT Count
thank you
Velox Letum
12-03-2005, 03:21 AM
SELECT COUNT(field) AS count FROM table
Then you can specify to select other fields, or WHERE clauses, but then you move into GROUP BY which can get a bit tricky. COUNT() counts the number of rows retrieved from the field. The AS count makes it easier to work with as the returned value would be in a virtual field called count. Example:
mysql> SELECT COUNT(id) as count FROM data;
+-------+
| count |
+-------+
| 33 |
+-------+
1 row in set (0.01 sec)
vBulletin® v3.8.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.