当前位置:Gxlcms > mysql > mysql中实现WITHAS语句

mysql中实现WITHAS语句

时间:2021-07-01 10:21:17 帮助过:703人阅读

mysql

WITH n(parentId) AS
(SELECT menuId

FROM TSYS_MENU

WHERE menuid in

#{item}

UNION ALL
SELECT parentId

FROM TSYS_MENU

WHERE menuid in

#{item}


UNION ALL

SELECT nplus.parentId

FROM TSYS_MENU as nplus, n

WHERE n.parentId = nplus.menuid)

SELECT distinct parentId FROM n where parentId is not null

    代码如上,如何在mysql中转换

人气教程排行