当前位置: 首页 > 知识库问答 >
问题:

选择列表不在GROUP BY子句中,且包含非聚合列…与SQL_MODE=Only_FULL_GROUP_BY不兼容

常光明
2023-03-14
SELECT *
FROM `tbl_customer_pod_uploads`
WHERE `load_id` = '78' AND
      `status` = 'Active'
GROUP BY `proof_type`

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

我需要像这样的结果

+----+---------+---------+---------+----------+-----------+------------+---------------+--------------+------------+--------+---------------------+---------------------+
| 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 |
+----+---------+---------+---------+----------+-----------+------------+---------------+--------------+------------+--------+---------------------+---------------------+

共有1个答案

崔恺
2023-03-14

这个

SELECT列表的表达式#1不在GROUP BY子句中,并且包含非聚合列'RETURNTR_PROd.tbl_CUSTOMER_POD_UPLOADS.ID',该列在功能上不依赖于GROUP BY子句中的列;这与sql_mode=only_full_group_by不兼容

将通过以下命令更改MySQL中的sql模式来简单地解决,

SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
 类似资料: