部分轉載至
SELECT
u2.*
FROM
(
SELECT
@ids AS p_ids,
( SELECT @ids := GROUP_CONCAT( id ) FROM oa_department WHERE FIND_IN_SET( pid, @ids ) ) AS c_ids,
@l := @l + 1 AS LEVEL
FROM
oa_department,
( SELECT @ids := ‘10’, @l := 0 ) b
WHERE
@ids IS NOT NULL
) u1
JOIN oa_department u2 ON FIND_IN_SET( u2.id, u1.p_ids )
AND u2.id != ‘10’;
本作品採用《CC 協議》,轉載必須註明作者和本文連結