WITH lmenu(MenuId,MenuName,MenuParentId,level)
as
(
SELECT MenuId,MenuName,MenuParentId,0 level FROM MenuInfo where MenuParentId=0
UNION ALL
SELECT A.MenuId, A.MenuName,A.MenuParentId,b.level+1 FROM MenuInfo A,lmenu b
where a.MenuParentId = b.MenuId
)
前两天春春搞的,你看下嘛
谢了