a.style=b.noselect count(no) as 总数 ,style as 类别  from a where valid>0  and userno<>0 group by style order by style ascselect name as 类别名称 from b 问题 如何将两个表的查询结果链接起来
显示方式总数     类别  类别名称50        10    蔬果 

解决方案 »

  1.   


    select *,name as 类别名称 from b,(
    select count(no) as 总数 ,style as 类别  from a where valid>0  and userno <>0 group by style order by style asc 
    )a
    on a.类别=b.no
      

  2.   

    条件不全啊。用表连接查询就行啊。inner join 什么的
      

  3.   


    select *,name as 类别名称 from b,(
    select count(no) as 总数 ,style as 类别  from a where valid>0  and userno <>0 group by style order by style asc 
    )a
    on a.类别=b.no
      

  4.   

    select count(a.no) as 总数 ,a.style as 类别,b.name as 类别名称  from a, b where valid>0  and userno <>0 group by style order by style asc 
      

  5.   

    select 
      count(a.no) as 总数 ,
      a.style as 类别,
      b.name as  类别名称
    from 
      a 
    left join b on a.style=b.no
    where 
      a.valid>0  and a.userno <>0 
    group by 
      a.style,
      b.name 
    order by 
      a.style asc