首頁 >資料庫 >mysql教程 >mysql中实现WITH AS语句

mysql中实现WITH AS语句

WBOY
WBOY原創
2016-06-06 09:33:306902瀏覽

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

<code>    代码如上,如何在mysql中转换</code>
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn