mysql count max min 语句用法

count 用法 求总条数

$sql="select count(*) as total from e_user";
$query = mysql_query($sql, $link);
$res = mysql_fetch_array($query);
$count = $res['total'];

max用法

$sql="select max(id) as maxid from e_user";
$sql="select id as maxid from e_user order by id desc limit 0,1";

min用法

$sql="select min(id) as minid from e_user";
$sql="select id as minid from e_user order by id desc limit 0,1";

sum 用法 求总和

$sql="select sum(id) as total from e_user";

AVG 用法 求平均值

$sql="select avg(id) as total from e_user";
上一篇:Most Powerful(ZOJ 3471状压dp)


下一篇:【移动开发】安卓Lab2(02)