【发布时间】:2020-03-20 17:11:28
【问题描述】:
我在服务器上遇到错误,但在本地主机上工作正常。我正在使用 laravel 邻接列表https://github.com/staudenmeir/laravel-adjacency-list:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'recursive `laravel_cte` as ((select *, 1 as `depth`, cast(`id` as char(65535)) a' at line 1 (SQL: with recursive `laravel_cte` as ((select *, 1 as `depth`, cast(`id` as char(65535)) as `path` from `user_relations` where `user_relations`.`parent_id` = 10000 and `user_relations`.`parent_id` is not null) union all (select `user_relations`.*, `depth` + 1 as `depth`, concat(`path`, '.', `user_relations`.`id`) from `user_relations` inner join `laravel_cte` on `laravel_cte`.`id` = `user_relations`.`parent_id`)) select count(`id`) as aggregate from `laravel_cte` where `status` = 0)
请帮我解决它,因为我是这种复杂的 mySQL/MariaDB 开发的新手,所以我一无所知。
【问题讨论】:
-
您的本地和生产 mariadb 版本是什么? (报错信息表示mariadb,不是mysql。它们很相似,但又不一样)
-
@Shadow 谢谢,我已经更新了服务器 MariaDB 版本,它运行良好。 Plz post是一个答案。你节省了我很多时间
标签: php mariadb common-table-expression