問題描述
在帶有 WAMP 服務器的 Windows PC 上使用 MySQL 5.7.13 的 AM
AM using MySQL 5.7.13 on my windows PC with WAMP Server
我的問題是在執行這個查詢時
Here my Problem is While executing this query
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 不兼容
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'returntr_prod.tbl_customer_pod_uploads.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
你能告訴我最好的解決方案嗎...
Can you please tell me the best solution...
我需要像這樣的結果
+----+---------+---------+---------+----------+-----------+------------+---------------+--------------+------------+--------+---------------------+---------------------+
| 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 |
+----+---------+---------+---------+----------+-----------+------------+---------------+--------------+------------+--------+---------------------+---------------------+
推薦答案
這個
SELECT 列表的表達式 #1 不在 GROUP BY 子句中,并且包含非聚合列returntr_prod.tbl_customer_pod_uploads.id",該列在功能上不依賴于 GROUP BY 子句中的列;這與 sql_mode=only_full_group_by 不兼容
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'returntr_prod.tbl_customer_pod_uploads.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
通過這個命令改變MySQL中的sql模式就可以解決了,
will be simply solved by changing the sql mode in MySQL by this command,
SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
這對我也有用..我用了這個,因為在我的項目中有很多這樣的查詢所以我只是把這個sql模式改成了only_full_group_by
This too works for me.. I used this, because in my project there are many Queries like this so I just changed this sql mode to only_full_group_by
OR 僅包含 SELECT 語句指定的 GROUP BY 子句中的所有列.sql_mode 可以保持啟用狀態.
OR simply include all columns in the GROUP BY clause that was specified by the SELECT statement. The sql_mode can be left enabled.
謝謝... :-)
這篇關于SELECT 列表不在 GROUP BY 子句中并且包含非聚合列......與 sql_mode=only_full_group_by 不兼容的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!