aiyali

导航

mysql 8.0 单表递归查询

数据结构

 

 

SQL

with recursive cte as
(
select * from e_solution where `code`='10001'
union all
select c.* from e_solution as c,cte where c.code=cte.peer_code
)
select * from cte;

 

结果

 

官方文档:https://dev.mysql.com/doc/refman/8.0/en/with.html#common-table-expressions-recursive

posted on 2018-12-28 17:51  aiyali  阅读(511)  评论(0)    收藏  举报