向上 WITH RECURSIVE r AS ( SELECT * FROM acu_customercircle WHERE circleunitid = 'd05c24fa-dc32-4357-8a48-0f72efdfd85a' union ALL SELECT acu_customercircle.* FROM acu_customercircle, r WHERE acu_customercircle.circleunitid = r.guidparentid) SELECT * FROM r ORDER BY circleunitid; 向下 WITH RECURSIVE T (circleunitid, strname, guidparentid, dwgrade) AS ( SELECT circleunitid, strname, guidparentid, dwgrade FROM acu_customercircle WHERE circleunitid = '712a9d32-e7d9-41d7-b07f-42a2e8c4a827' UNION ALL SELECT D.circleunitid, D.strname, D.guidparentid, D.dwgrade FROM acu_customercircle D JOIN T ON D.guidparentid = T.circleunitid) SELECT circleunitid, strname, guidparentid, dwgrade FROM T ORDER BY dwgrade;
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/6713.html