用户表:nt_user
id 自动编译
username 用户名
.........统计表:nt_title
titleid 自动编译
titleuser 用户名 与nt_user 的username 用户名相等
......
图片表:Nt_Imgbook
id 自动编译
titleid 与 nt_score的titleid 相等
...
评分表:nt_score
imageid (字段)与Nt_Imgbook的 id 相等
score 分数
count 张数
我想要的是排列所有用户的精华图片,(条件是score>100),还有的就是统计属于这个用户有多少张精华图片下面是我写的。。但是只得到一个用户的(还有的就是我没有用到用户表)
SELECT TOP 13 titleuser, count(count) AS f FROM nt_title,Nt_score,Nt_Imgbook WHERE Nt_Imgbook.id=Nt_score.imageid and nt_title.titleid=Nt_Imgbook.titleid and score>100 GROUP BY titleuser
ORDER BY count(icount) DESC;
id 自动编译
username 用户名
.........统计表:nt_title
titleid 自动编译
titleuser 用户名 与nt_user 的username 用户名相等
......
图片表:Nt_Imgbook
id 自动编译
titleid 与 nt_score的titleid 相等
...
评分表:nt_score
imageid (字段)与Nt_Imgbook的 id 相等
score 分数
count 张数
我想要的是排列所有用户的精华图片,(条件是score>100),还有的就是统计属于这个用户有多少张精华图片下面是我写的。。但是只得到一个用户的(还有的就是我没有用到用户表)
SELECT TOP 13 titleuser, count(count) AS f FROM nt_title,Nt_score,Nt_Imgbook WHERE Nt_Imgbook.id=Nt_score.imageid and nt_title.titleid=Nt_Imgbook.titleid and score>100 GROUP BY titleuser
ORDER BY count(icount) DESC;
解决方案 »
- 性能影响求教:方法中参数类型为控件类型(如 fun(GridView gv))
- 关于用AJAX验证表单的问题?
- asp.net 如何 动态构造地址栏参数
- 在Web页面上直接打开、编辑、创建word和EXCEL文件 怎么实现?
- 十万火急!access数据库更新的奇怪问题!(跪求啊!!!)
- 跪错误“SqlParameter”方法没有采用“9”个参数的重载
- 大家讨论讨论: 面向对象与Asp.net开发
- 请问哪里有免费的支持ASP.NET2.0+SQLSERVER2000的空间?
- 公司实习生求救
- 紧急求助:本人要在iframe里调用搜狐,当点击搜狐里的超级链接时都在这个frame里打开,怎么处理?
- LIstView控件后台数据绑定及分页处理问题?
- IT迷途羔羊!请大家指点!
图片表的图片字段是什么?
nt_score 的 imageid (字段)与Nt_Imgbook的 id 相等
from (select titleuser ,id from nt_title a left join Nt_Imgbook b on a.titleid =b.titleid
group by titleuser ,id
) a left join nt_score b on a.id=b.imageid where b.count >1500
试试。。不知道是不是你要的,
看看结果是什么。。
id 自动编译
username 用户名
......... 统计表:nt_title
titleid 自动编译
titleuser 用户名 与nt_user 的username 用户名相等
......
图片表:Nt_Imgbook
id 自动编译
titleid 与 nt_score的titleid 相等
...
评分表:nt_score
imageid (字段)与Nt_Imgbook的 id 相等
score 分数
count 张数
我想要的是排列所有用户的精华图片,(条件是score>100),还有的就是统计属于这个用户有多少张精华图片
用户表.username 用户名 与 nt_title 的titleuser 用户名相等
nt_title.titleid=Nt_Imgbook .titleid
Nt_Imgbook .id=nt_score .imageid
group by titleuser ,id
) a left join nt_score b on a.id=b.imageid where b.count >1500
如果正确的话应该是
admin 7
zhangsan 4
wangwu 2
lisi 1
你先执行里面那条,看查出的结果。select a.titleuser ,count(count) as c from (select titleuser ,id from nt_title a left join Nt_Imgbook b on a.titleid =b.titleid
group by titleuser ,id
) a left join nt_score b on a.id=b.imageid where b.score>100