id  ,parent_id 上下级的定义

select id from (
               select t1.id,t1.parent_id,
               if(find_in_set(parent_id, @pids) > 0, @pids := concat(@pids, ',', id), 0) as ischild
               from (
                    select id,parent_id from sys_org t where t.del_flag = '0' order by parent_id, id
                   ) t1,
                   (select @pids := '1') t2
              ) t3 where ischild != 0;