此查询在我的本地环境中碰巧成功,但在远程环境中失败。
WITH RECURSIVE category_paths (id, title, path) AS
(
SELECT id, title, title as path
FROM articulo_categoria
WHERE parentId IS NULL
UNION ALL
SELECT c.id, c.title, CONCAT(cp.path, ' > ', c.title)
FROM category_paths AS cp JOIN articulo_categoria AS c
ON cp.id = c.parentId
)
SELECT * FROM category_paths
ORDER BY path;
返回的错误是: SQLSTATE [42000]:语法错误或访问冲突:1064 SQL语法有错误;检查与您的MariaDB服务器版本相对应的手册以获取正确的语法,以在'RECURSIVE category_path(id,title,parentId)AS ...
附近使用