Faster way to know the total number of rows in MySQL database?
- by Starx
If I need to know the total number of rows in a table of database I do something like this:
$query = "SELECT * FROM tablename WHERE link='1';";
$result = mysql_query($query);
$rows = mysql_fetch_array($result);
$count = count($rows);
So you see the total number of data is recovered scanning through the entire database.
Is there a better way?