2025-07-18 15:50:49 +08:00

12 lines
269 B
Plaintext

select x.*, 'folder' as rtype,
case when y.id is null then 1
else 0 end as is_leaf
from
(select * from folder
where parentid is null) x left join
(select unique a.* from
folder a left join folder b
on a.id = b.parentid
where b.id is not NULL) y
on x.id = y.id