【问题标题】:Laravel 5.8 SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntaxLaravel 5.8 SQLSTATE [42000]:语法错误或访问冲突:1064 您的 SQL 语法有错误
【发布时间】:2020-05-03 08:00:21
【问题描述】:

SQLSTATE[42000]: 语法错误或访问冲突:1064 您的 SQL 语法有错误;检查与您的 MariaDB 服务器版本相对应的手册,以在第 1 行的“从contacts order by created_at desc limit 10 offset 0”附近使用正确的语法(SQL:select from contacts order by created_at desc限制 10 偏移 0)

【问题讨论】:

  • 您实际上并没有选择任何列,因为您可以看到您的查询是select from contacts order by created_at desc limit 10 offset 0。您需要在selectfrom 之间添加您选择的列。
  • 使用 DB::enableQuerylog 和 DB::getQuerylog 进行调试
  • 嗨,请包含一些代码,以便我们知道问题所在。
  • 你是如何执行你的请求的?

标签: php laravel laravel-5.8


【解决方案1】:

根据错误消息,我猜您需要更新您的查询

select * from contacts order by created_at desc limit 10 offset 0

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-02-15
    • 1970-01-01
    • 1970-01-01
    • 2020-03-02
    • 2019-08-08
    • 2021-09-15
    • 1970-01-01
    相关资源
    最近更新 更多