select * from (
select t1.*,
if(find_in_set(ac_pid, @pids) > 0, @pids := concat(@pids, ',', rc_id), 0) as ischild
from (
select * from ".$this->trueTableName." t where t.is_show = 1 order by sort asc,rc_id asc
) t1,
(select @pids := 226) t2
) t3 where ischild != 0
里面替换两个字段就好,一个$this->trueTbaleName表明
ac_pid对应的父亲id字段
rc_id 标识id
is_show =1 查询不隐藏的
排序方式
sort asc 和rc_id asc
226查询rc_id =226下面所有子菜单
方法2:
就是存储过程和方法
我的是navcat里面创建的
BEGIN
#Routine body goes here...
drop TEMPORARY TABLE IF EXISTS tmpLst;
create TEMPORARY TABLE IF NOT EXISTS tmpLst (
sno INT PRIMARY KEY AUTO_INCREMENT,
id INT,
depth INT
);
call router_access_childlist(rootId,0);
select
mami_router_access.rc_id,
mami_router_access.ac_pid,
mami_router_access.node_name,
tmpLst.depth
FROM tmpLst,mami_router_access
WHERE tmpLst.id=channel.rc_id ORDER BY tmpLst.sno;
END
里面创建的时候首先rootId 类型的int
保存的方法名为router_access_childlist