首页 >数据库 >mysql教程 >mysql如何实现递归等级查询

mysql如何实现递归等级查询

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原创
2016-06-06 09:34:321882浏览

mysql递归oracle

在oracle中
select max(level) into max_level
from zj_template_option t
where t.enable = '1'
and t.template_id = '5'
--and level >='3'
and t.ispfx = '1'
start with t.pid = '0'
connect by prior t.id = t.pid
order by template_id;
把它改成mysql 如何实现,及查询的结果为
id pid level
1 0 1
2 1 2
......

<code>大神能给个这样的函数吗</code>
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn