PDA

View Full Version : how to use SELECT Count


niluj
12-03-2005, 01:29 AM
how to use SELECT Count
thank you

Velox Letum
12-03-2005, 02: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)