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
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
本文标题:SQL 查询所有下级
本文链接:https://www.haomeiwen.com/subject/ncesphtx.html
网友评论