摘要:
本文转载http://www.cnblogs.com/xqhppt/archive/2011/02/15/1955366.htmlwithcteas(selectId,Pid,DeptName,0aslvlfromDepartmentwhereId=2unionallselectd.Id,d.Pid,d.DeptName,lvl+1fromctecinnerjoinDepartmentdonc.Id=d.Pid)select*fromcte1表结构IdPidDeptName------------------------------------------------------------- 阅读全文