求一个统计数据库 所有表的记录条数的总和的语句(mysql)

求一个统计数据库 所有表的记录条数的总和的语句(mysql)或者其他方法

第1个回答  2011-03-15
<?php
mysql_connect('localhost','数据库帐号','数据库密码');
mysql_select_db('数据库名');

$result = mysql_query('show tables'); //获取所有表名

$all_record = 0;
while($record = mysql_fetch_row($result)) {
$tb_name = $record[0]; //表名

$n = mysql_result(mysql_query('select count(*) from `'.$tb_name.'`'),0);
$all_record+=$n;
}

echo $all_record; //总记录数

?>追问

这个要在那里执行?

追答

这个是 PHP 代码啊

追问

我现在 已经解决了 用的sql语句 配合excel

本回答被提问者采纳
第2个回答  2011-03-17
select count(*) from table;
相似回答