Mysql Query – Get Number of Rows in a Mysql Database Table
March 5th, 2009
No comments
1'st Solution, use Mysql COUNT(*) :
$sql = "SELECT COUNT(*) FROM my_table";
$result = mysql_query($sql);
$num = mysql_result($result, 0);
echo $num;
2'nd solution: use TABLE_ROWS and TABLE_NAME from information_schema:
$query = "select TABLE_ROWS from information_schema.tables where table_schema = 'my_data_base' AND TABLE_NAME = 'my_table' ";
$result = mysql_query($query);
$count ...
Categories: Bookmarks, MySQL, Networking, PhP, Tech get count row, information_schema, Mysql COUNT, mysql row counts, SELECT COUNT, TABLE_NAME, TABLE_ROWS, table_schema








