Laravel 5.3: Syntax error or access violation: 1463 Non-grouping field #39;distance#39; is used in HAVING clause(Laravel 5.3:语法错误或访问冲突:1463 HAVING 子句中使用了非分组字段“距离)
问题描述
将整个源代码移至 5.3 版本后出现此错误,我现在挠头两个多小时了.
This error came up after moving the whole source to the 5.3 version, and I'm scratching my head for over two hours now.
所以我有这种雄辩的查询:
So I have this kind of eloquent query:
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();
它在升级之前找到了现在它抛出:
It worked find before upgrade now it throws:
语法错误或访问冲突:1463 非分组字段距离"用于 HAVING 子句 (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) have distance <= 6 order by distance asc)
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
poiwherestatus= 1 andidnot in (1) havingdistance<= 6 order bydistanceasc)
我想检查我的服务器上是否启用了 ONLY_FULL_GROUP_BY 模式,但它不是...
I wanted to check if the ONLY_FULL_GROUP_BY mode is enabled on my server, but it isn't...
选择@@sql_modeNO_ENGINE_SUBSTITUTION
SELECT @@sql_mode NO_ENGINE_SUBSTITUTION
同样的查询在 MySQL 工作台中运行良好.怎么回事?
The same query works fine in MySQL workbench. What's going on?
推荐答案
查看mysql连接中的config/database.php文件,strict为false:
Check in the config/database.php file in the mysql conection that the strict is false:
'strict' => false,
如果为真,则为假.
这篇关于Laravel 5.3:语法错误或访问冲突:1463 HAVING 子句中使用了非分组字段“距离"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Laravel 5.3:语法错误或访问冲突:1463 HAVING 子句中使用了非分组字段“距离"
基础教程推荐
- 无法解决整理冲突 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
