SQL在一张表中根据父ID获取所有的子ID

with a as (
select id,name,parentid from categories where id=53
union all
select x.id,x.name,x.parentid from categories x,a where x.parentid=a.id
)
select * from a

 

posted @ 2018-07-06 14:58  chenxizhaolu  阅读(950)  评论(0编辑  收藏  举报