SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax;check..

9 篇文章 0 订阅
2 篇文章 0 订阅

 

laravel 报错,这个报错很长,如下:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'concat(path,id) as paths from `web_node` order by `paths` asc' at line 1 (SQL: select ,concat(path,id) as paths from `web_node` order by `paths` asc)

 

乍一看其实没什么问题,但是我一看代码之后就恍然大悟,原来是我没写要查询的字段,代码如下:

// 结点表数据
$node = Node::select(DB::raw(',concat(path,id) as paths'))->orderBy('paths')->get()->toArray();

看出什么问题了吧,没加要查的字段,加上吧:

// 结点表数据
$node = Node::select(DB::raw('*,concat(path,id) as paths'))->orderBy('paths')->get()->toArray();

这个问题其实不该出现,但是代码调试的时候难免出现这种情况,所以...习以为常!

 

 

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值