mysqlメニューの下にあるすべてのサブメニューのsqlを取得
1750 ワード
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
2つのフィールドを置換すればいいです.1つの$->thistrueTbaleNameは
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