从SQL Server到MySQL的递归CTE转换

时间:2015-08-12 11:06:57

标签: mysql sql-server

有没有人可以帮我将以下查询更改为mysql格式:

DECLARE @userTypeId INT;
SET @userTypeId = 1;

WITH tblChild AS
(SELECT *
        FROM category WHERE parent_id = @userTypeId
    UNION ALL
    SELECT category.* FROM category  
    JOIN tblChild  ON category.parent_id = tblChild.Id
)
SELECT *
    FROM products where category_id in (select id from tblChild)
OPTION(MAXRECURSION 32767)

0 个答案:

没有答案