WITH sys_region
AS (
--起始条件
SELECT code, name, parent_code,type
FROM sys_region_country
WHERE code='511722000000' --列出子节点查询条件
UNION ALL
--递归条件
SELECT a.code, a.name,a.parent_code,a.type
FROM sys_region_country a
INNER JOIN sys_region b --执行递归,这里就要理解下了
ON a.code = b.parent_code --此处可以交换子级
)
SELECT code,name,parent_code,type FROM sys_region order by type