以下代码参考的是社区里面一位大侠的
select *,(select count(*) from tree where parentid = T.id and dirid=id) as children from tree T where parentid = 0 and dirid=id select *,(select count(*)
select *,(select count(*) from tree where parentid = T.id and dirid=id) as children from tree T where parentid = 0 and dirid=id select *,(select count(*)