SELECT T2.*
FROM (
SELECT
@r AS _id,
(SELECT @r := PAR_MENU_ID FROM TS_SYS_MENU WHERE MENU_ID = _id) AS PAR_MENU_ID,
@l := @l + 1 AS lvl
FROM
(SELECT @r := 32, @l := 0) vars,
TS_SYS_MENU h
WHERE @r <> 0) T1
JOIN TS_SYS_MENU T2
ON T1._id = T2.MENU_ID
ORDER BY T1.lvl DESC;
网友评论