欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

mysql中实现WITH AS语句

程序员文章站 2024-01-07 18:19:40
...
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中转换
相关标签: mysql