什么都不说直接上干货。
with subqry(id,ParDictID,DictCode) as (--ParDictID是id的parentid
select id,ParDictID,DictCode from SYS_Dictionary where id = '24612e1e-4810-4f31-9135-61a3a909df3c'
union all
select SYS_Dictionary.id,SYS_Dictionary.ParDictID,SYS_Dictionary.DictCode from SYS_Dictionary,subqry where SYS_Dictionary.ParDictID = subqry.id
)
select DictCode from subqry;