我用WAMP服务器在我的windows PC上使用MySQL 5.7.13

我的问题是在执行这个查询时

SELECT *
FROM `tbl_customer_pod_uploads`
WHERE `load_id` = '78' AND
      `status` = 'Active'
GROUP BY `proof_type`

我总是得到这样的错误

SELECT列表中的表达式#1不在GROUP BY子句中,包含未聚合的列returntr_prod.tbl_customer_pod_uploads。id',它不依赖于GROUP BY子句中的列;这与sql_mode=only_full_group_by不兼容

你能告诉我最好的解决办法吗?

我需要这样的结果

+----+---------+---------+---------+----------+-----------+------------+---------------+--------------+------------+--------+---------------------+---------------------+
| id | user_id | load_id | bill_id | latitude | langitude | proof_type | document_type | file_name    | is_private | status | createdon           | updatedon           |
+----+---------+---------+---------+----------+-----------+------------+---------------+--------------+------------+--------+---------------------+---------------------+
|  1 |       1 | 78      | 1       | 21.1212  | 21.5454   |          1 |             1 | id_Card.docx |          0 | Active | 2017-01-27 11:30:11 | 2017-01-27 11:30:14 |
+----+---------+---------+---------+----------+-----------+------------+---------------+--------------+------------+--------+---------------------+---------------------+

当前回答

> sudo nano /etc/mysql/my.cnf

输入下面的

[mysqld]
sql_mode = ""

Ctrl + O => Y = Ctrl + X

> sudo service mysql restart

其他回答

还可以简单地将GROUP_CONCAT()添加到非聚合列中。

像GROUP_CONCAT (your_column)

打开WAMP面板,打开MySQL配置文件。在其中,如果找到“sql_mode”,则搜索它,将其设置为“”,否则,如果没有找到它,则在文件中添加sql_mode=“”。

重新启动MySQL服务器,你就可以开始了…

快乐的编码。

登录到phpMyAdmin 导航到:服务器:http://localhost/phpmyadmin,不要选择任何数据库 点击SQL从顶部菜单和虫害下面的代码运行SQL查询/查询服务器 SET GLOBAL sql_mode=(SELECT (@@sql_mode,'ONLY_FULL_GROUP_BY', ")); 比照链接

这里有一个非常快速和简单的方法来永久设置它

注意:running SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY', "));是临时的,在服务器重新启动时,仍然会出现错误。 要永久修复这个问题,请执行以下操作

以根用户身份登录到服务器 在终端运行中 wget https://gist.githubusercontent.com/nfourtythree/90fb8ef5eeafdf478f522720314c60bd/raw/disable-strict-mode.sh 执行chmod +x disable-strict-mode.sh使脚本可执行 执行。/disable-strict-mode.sh

完成后,mysql将被修改,并将重新启动

For the query to be legal in SQL92, the name column must be omitted from the select list or named in the GROUP BY clause. SQL99 and later permits such nonaggregates per optional feature T301 if they are functionally dependent on GROUP BY columns: If such a relationship exists between name and custid, the query is legal. This would be the case, for example, were custid a primary key of customers. MySQL 5.7.5 and up implements detection of functional dependence. If the ONLY_FULL_GROUP_BY SQL mode is enabled (which it is by default), MySQL rejects queries for which the select list, HAVING condition, or ORDER BY list refer to nonaggregated columns that are neither named in the GROUP BY clause nor are functionally dependent on them. via MySQL :: MySQL 5.7 Reference Manual :: 12.19.3 MySQL Handling of GROUP BY

你可以用下面的命令改变sql模式来解决这个问题:

SET GLOBAL sql_mode=(SELECT (@@sql_mode,'ONLY_FULL_GROUP_BY', "));

和…记得重新连接数据库!!