解决mysql报错this is incompatible with DISTINCT

环境

centos 9

php7.4

mysql5.7

问题

mysql查询报如下错误:

sql 复制代码
SQLSTATE[HY000]: General error: 3065 Expression #1 of ORDER BY clause is not in SELECT list, references column 'hst_csc.q.timestamp' which is not in SELECT list; this is incompatible with DISTINCT

解决方案

解决方案是在mysql配置文件中加一行

vim /etc/my.cnf

ini 复制代码
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGI
NE_SUBSTITUTION

重启mysql服务

systemctl restart mysqld

相关推荐
阿蒙Amon30 分钟前
C#读写文件:多种方式详解
开发语言·数据库·c#
东窗西篱梦1 小时前
Redis集群部署指南:高可用与分布式实践
数据库·redis·分布式
就是有点傻2 小时前
C#如何实现中英文快速切换
数据库·c#
1024小神2 小时前
hono框架绑定cloudflare的d1数据库操作步骤
数据库
KellenKellenHao4 小时前
MySQL数据库主从复制
数据库·mysql
@ chen4 小时前
Redis事务机制
数据库·redis
KaiwuDB4 小时前
使用Docker实现KWDB数据库的快速部署与配置
数据库·docker
一只fish5 小时前
MySQL 8.0 OCP 1Z0-908 题目解析(16)
数据库·mysql
泊浮目5 小时前
未来数据库硬件-网络篇
数据库·架构·云计算
静若繁花_jingjing6 小时前
Redis线程模型
java·数据库·redis