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 蔬果
显示方式总数 类别 类别名称50 10 蔬果
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
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
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