SELECT ID.temp_level, DATA.* FROM ( SELECT @idsAS _ids, ( SELECT@ids := GROUP_CONCAT( region_id ) FROM region WHERE FIND_IN_SET( parent_id, @ids ) ) AS cids, @l :=@l+1AS temp_level FROM region, ( SELECT@ids :=3, @l :=0 ) b WHERE @idsISNOTNULL ) ID, region DATA WHERE FIND_IN_SET( DATA.region_id, ID._ids ) ORDERBY temp_level