Home > Database > Mysql Tutorial > mysql中实现WITH AS语句

mysql中实现WITH AS语句

WBOY
Release: 2016-06-06 09:33:30
Original
6911 people have browsed it

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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template