解决mysql报错this is incompatible with DISTINCT

环境

centos 9
php7.4
mysql5.7

问题

mysql查询报如下错误:

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

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

你可能感兴趣的:(mysql,数据库)