Tag: adjacency list

如何将MSSQL CTE查询转换为MySQL?

在我的MySQL架构中,我有category(id, parentid, name)表 在MSSQL中,我有CTE查询(从底层开始为所提供的类别ID构build一个类别树: with CTE (id, pid, name) as ( select id, parentid as pid,name from category where id = 197 union all select CTE.pid as id , category.parentid as pid, category.name from CTE inner join category on category.id = CTE.pid ) select * from CTE 如何将该查询转换为MySQL?