PHP统计数据语句 php数据统计分析

求php统计查询语句SELECTconcat("2010-4-4" ,' - ', "2010-5-4") as period,sum(B) as summary FROM demo where A ="2010-4-4"and A"2010-5-4"
union
SELECT concat("2010-5-4" ,' - ',"2010-6-3") as period,sum(B)as summary FROM demo whereA="2010-5-4" and A "2010-6-3"
===============
注意:我示例SQL中的具体的日期应该用你程序传进来的日期变量名代替.
如:="2010-5-4"换成 =".$from_date."
========
示例中A列假定字段类型为date,上述语句在我的系统测试通过.
php 怎么统计数据表某一个表的大小,不是记录数?。。?/h2>这个需要查询 information_schema.TABLES. 其中的 data_length 就是你要的...
给你个查询数据库大小的语句.
select concat(round(sum(DATA_LENGTH/1024/1024),2), ' M') as dbsize from information_schema.TABLES where table_schema= 'mysql';
价格 where 条件就可以指定单个表了.
select concat(round(sum(DATA_LENGTH/1024/1024),2), ' M') as dbsize from information_schema.TABLES where table_schema= 'mysql' and table_name='user';
php怎么统计mysql表里有多少数据,怎么把比如user里面的数据全部显示出来$conn
=
mysql_connect('localhost','root','123');
mysql_select_db('db_name');
//数据库名
【PHP统计数据语句 php数据统计分析】mysql_query('set
names
utf8',$conn);
#$res
=
mysql_query('select
count(*)
from
user',$conn);
//统计user表里总共有多少条数据
#$res
=
mysql_query('select
*
from
user',$conn);
//把user里面的数据全部显示出来
$arr
=
array();
while($data
=
mysql_fetch_assoc($res))
{
$arr[]
=
$data;
}
print_r($arr);
可以依次把上面查询语句前面的注释去掉查看效果
PHP如何统计数据库中某一列重复最多的一个值SELECT xx1,COUNT(xx1) AS c FROM 表名 GROUP BY xx1 ORDER BY c DESC
使用COUNT结合GROUP BY去查询,得到的结果再进行排序即可 。这样不需要用到PHP,只要一个SQL语句就搞定了 。
关于PHP统计数据语句和php数据统计分析的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

    推荐阅读