查询子节点 postgresql

查询子节点 postgresql_第1张图片
数据库为postgresql

WITH RECURSIVE cte AS (
	SELECT
		n. ID,
		n. com_name,
		n."parentId" AS pid
	FROM
		company AS n
	WHERE
		n. ID = 2
	UNION ALL
		SELECT
			r. ID,
			r. com_name,
			cte. ID AS pid
		FROM
			cte
		JOIN company AS r ON r.

你可能感兴趣的:(VIP专栏,postgresql)