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

Posted chenxizhaolu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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

 

以上是关于SQL在一张表中根据父ID获取所有的子ID的主要内容,如果未能解决你的问题,请参考以下文章