博客中评论条数的统计 如有个commtent表: 属性 字段 描述 id int 主键 自增 contents text 内容 author varchar(50) 作者 Art_id int 另一个表的主键且自增 现在要根据有多少个相同的Art_id统计出 每个不同的Art_id的数量,Art_id会随时变化! 请问如何建一个表来保存统计 出来的数量 用sql server 2005 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 因为数据是动态变化的,你可以创建一个视图,然后从这个视图中取数据就可以了。create view 评论统计 as select count(Art_id) from commtent group by Art_id不然的话你也可以直接通过sql语句计算文章的评论数。 恩,没必要建一个表来存统计数量,因为你都说了,是动态变的那就每次需要时用sql搜出来就可以了select Art_id,count(1) from commtent group by Art_id 为什么需要保存?查出count就行了吧。据说这些东西用缓存可以提高80%以上的效率 建评论实体类,有一属性关联文章实体类通过文章ID查询查询评论数,或用视图查询数据select count(Art_id) from commtent group by Art_id select Art_id,count(1) from commtent group by Art_id aspx页面上画线路图-高手请进!!! 怎样用字符串获取实体类中的数据 100分帮忙调试个网站 我想实现一个读取大量数据AjaxTree,谁能给个实例? 哪有asp.net文本编辑器下载? 菜鸟问一个很菜的连接数据库的问题。 问个比较弱智的问题! 请教一个datagrid的问题 在iframe中如何刷新它的父页面 请教关于在datagrid模板列中事件响应的问题 求大侠们帮助小弟 产生随机链接 急求!datagrid绑定dropdownlist值得批量修改
create view 评论统计 as select count(Art_id) from commtent group by Art_id
不然的话你也可以直接通过sql语句计算文章的评论数。
那就每次需要时用sql搜出来就可以了select Art_id,count(1) from commtent group by Art_id
通过文章ID查询查询评论数,或用视图查询数据
select count(Art_id) from commtent group by Art_id
select Art_id,count(1) from commtent group by Art_id