艺海无涯,学无止境。欢迎一起探讨技术和人生,了解我

Mysql递归查询所有子项

WITH RECURSIVE result(id, routename ,routeurl,typeid ,parentid) AS (SELECT id, routename ,routeurl,typeid ,parentid FROM auth_route WHERE id = 1 UNION ALL SELECT i.id, i.routename ,i.routeurl,i.typeid ,i.parentid FROM auth_route i JOIN result ON i.parentid = result.id) SELECT * FROM result