3492°

MySql获取树型结构的所有子节点

获取子节点, department_id

SELECT * FROM person WHERE department IN
(SELECT department_id FROM department WHERE department_id = 20006
UNION
(SELECT department_id FROM
  (SELECT  * FROM department ORDER BY parent_id,department_id) depart_sorted,
  (SELECT @pv := 20006) initialisation
WHERE find_in_set(parent_id,@pv)
AND length(@pv := concat(@pv,',',department_id))));

全部评论: 0

    我有话说: