SQL 查询所有下级

2020-04-15  本文已影响0人  戬谷stone

select *,ischild from (

select t1.*,

if(find_in_set(pid, @pids) > 0, @pids := concat(@pids, ',', id ), 0) as ischild

from (

  select * from hqf_member t order by pid, id

) t1,

(select @pids :=上级ID ) t2

) t3 where ischild

上一篇下一篇

猜你喜欢

热点阅读