[UPHPU] get count of database records matching criteria
Richard Miller
richardkmiller at gmail.com
Sat Feb 26 01:24:03 MST 2005
Wade,
See http://dev.mysql.com/doc/mysql/en/group-by-functions.html#id2928089
. I think either of these would work:
SELECT COUNT(*) FROM <table> WHERE age >= 55;
or
SELECT COUNT(age) FROM <table> WHERE age >= 55;
I couldn't tell from the manual if there is any speed difference
between these two statements.
Richard
On Feb 25, 2005, at 9:43 PM, Wade Preston Shearer wrote:
> What is the most efficient way to get a count of the number of rows in
> a MySQL database that match a certain criteria?
>
> For example, let's assume we have a database containing the following
> columns: name, age, weight. I want to have a numerical count of how
> many rows in the database contain a record of someone that is 55 years
> old. So, it will be counting only a portion of the entire table.
> _______________________________________________
>
> UPHPU mailing list
> UPHPU at uphpu.org
> http://uphpu.org/mailman/listinfo/uphpu
> IRC: #uphpu on irc.freenode.net
More information about the UPHPU
mailing list