gpt4 book ai didi

mysql - 拉维尔 5.3 : Syntax error or access violation: 1463 Non-grouping field 'distance' is used in HAVING clause

转载 作者:IT老高 更新时间:2023-10-29 00:18:22 26 4
gpt4 key购买 nike

这个错误是在将整个源代码移动到 5.3 版本后出现的,我现在挠头了两个多小时。

所以我有这种 Eloquent 查询:

POI::select('*', DB::raw("SQRT( POW((x - {$this->x}),2) + POW((y - {$this->y}),2) ) AS distance"))
->where('status', Config::get('app.poi_state.enabled'))
->whereNotIn('id', $excludePOIList)
->having('distance', '<=', $distance)
->orderBy('distance')->get();

它在升级之前找到了,现在它抛出:

Syntax error or access violation: 1463 Non-grouping field 'distance' is used in HAVING clause (SQL: select *, SQRT( POW((x - 860.0000),2) + POW((y - 105.0000),2) ) AS distance from poi where status = 1 and id not in (1) having distance <= 6 order by distance asc)

我想检查我的服务器是否启用了 ONLY_FULL_GROUP_BY 模式,但它没有...

SELECT @@sql_mode NO_ENGINE_SUBSTITUTION

相同的查询在 MySQL 工作台中运行良好。怎么回事?

最佳答案

在mysql连接中的config/database.php文件中检查strict为false:

'strict' => false,

如果为真,则输入假。

关于mysql - 拉维尔 5.3 : Syntax error or access violation: 1463 Non-grouping field 'distance' is used in HAVING clause,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39053335/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com