不要count(*)就可以了
select distinct a.belong as Idb.parentid as IdCount from Edu_Book as a inner join Edu_BookDir as b on a.belong=b.id group by a.belong order by a.belong
select distinct a.belong as Idb.parentid as IdCount from Edu_Book as a inner join Edu_BookDir as b on a.belong=b.id group by a.belong order by a.belong
那应该怎么办?如何修改?
LUJUN(陆天)
应该如何修改呢?
将 count(*),b.parentid as IdCount
改为 count(b.parentid) as IdCount
select a.belong as Id,count(*),b.parentid as IdCount
from Edu_Book as a inner join Edu_BookDir as b
on a.belong=b.id
group by a.belong, b.parentid另: 如果ORDER BY的字段和GROUP BY一样的话,不需要另外加上ORDER BY. GROUP BY自动根据所列的字段排序
谢谢,谢谢,能解释一下为什么group by中要加上b.parenti么?