用户表: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;

解决方案 »

  1.   

    想要的是排列所有用户的精华图片,(条件是score>100),还有的就是统计属于这个用户有多少张精华图片 
     图片表的图片字段是什么?
      

  2.   

    Nt_Imgbook 的titleid 与 nt_score的titleid 相等
    nt_score 的 imageid (字段)与Nt_Imgbook的 id 相等
      

  3.   

    select a.*,count(count) from nt_score 
    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
    试试。。不知道是不是你要的,
    看看结果是什么。。 
      

  4.   

    用户表: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),还有的就是统计属于这个用户有多少张精华图片 
    用户表.username 用户名 与 nt_title 的titleuser 用户名相等 
    nt_title.titleid=Nt_Imgbook .titleid
    Nt_Imgbook .id=nt_score .imageid
      

  5.   

    你的一个条件:SCORE>1000当然查不出所有用户的了
      

  6.   

    select a.*,count(count) 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 
      

  7.   

    where b.count >1500 这里条件应该是score>100,
      

  8.   

    出错,。。错误为》试图执行的查询中不包含作为合计函数的一部分的特定表达式“titleuser”
      

  9.   

    select titleuser,count(count) as f from (select *  from nt_title a left join Nt_Imgbook b on a.titleid =b.titleid) b left join nt_score c on b.id=c.imageid  where score>100 group by titleuser order by count(count) DESC我改成这样他只得到一个用户的显示  admin       7
    如果正确的话应该是       
       admin    7
      zhangsan  4
      wangwu    2
      lisi      1
      

  10.   

    ..
    你先执行里面那条,看查出的结果。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
      

  11.   

    出错,。。错误为》试图执行的查询中不包含作为合计函数的一部分的特定表达式“titleuser”