whats the syntax in getting the total number of rows in a particular table in an mysql database?
+10
A:
I've always done
SELECT count(*) from table
The above will you give you the total count of all rows.
You could just as easily tack on a WHERE clause to get the count of some subset
SELECT count(*) from table WHERE foo = 'bar'
Mark Biek
2009-03-01 18:27:41
+2
A:
COUNT(*) facts and myths:
MYTH: "InnoDB doesn't handle count(*) queries well":
Most count(*) queries are executed same way by all storage engines if you have a WHERE clause, otherwise you InnoDB will have to perform a full table scan.
FACT: InnoDB doesn't optimize count(*) queries without the where clause
Charles Faiga
2009-03-01 19:00:42
That would make it not a true myth, but something that is is true under limited circumstances only, including the circumstance in the original question: getting a count of all rows in a table.
thomasrutter
2009-03-02 04:47:44