sql 树形递归查询
sql 树形递归查询:
with ProductClass(ClassId,ClassName) as
(
select ClassId,ClassName from Classes where ClassId = 31281
union all
select c.ClassId,c.ClassName from Classes c inner join ProductClass parent on c.ParentClassId = parent.ClassId
)
select c.ClassId, c.ClassName, m.ProductId, m.ProductName
from ProductClass c
inner join Products m on c.ClassId = m.ClassId