相关表:t_directory

MySql 递归查询 层级

Sql:查询编码为1的directory的所有子级

select F_Id from (
              select t1.F_Id,
              if(find_in_set(F_ParentId, @pids) > 0, @pids := concat(@pids, ',', F_Id), 0) as ischild
              from (
                   select F_Id,F_ParentId from t_directory t order by F_ParentId, F_Id
                  ) t1,
                  (select @pids := (SELECT F_ID FROM T_Directory WHERE F_Code = '1') ) t2
             ) t3 where ischild != 0

相关文章: