【问题标题】:Getting error at server and working fine at localhost, Laravel CTE (Adjacency)在服务器上出现错误并在本地主机上正常工作,Laravel CTE(邻接)
【发布时间】: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


【解决方案1】:

“CTE”(WITH RECURSIVE ...) 在 MariaDB 10.2 或 MySQL 8.0 之前不可用。

【讨论】:

    猜你喜欢
    • 2018-10-22
    • 2015-11-13
    • 2012-05-22
    • 2018-03-07
    • 2015-08-28
    • 1970-01-01
    • 1970-01-01
    • 2019-12-17
    • 2023-03-06
    相关资源
    最近更新 更多