SELECT list is not in GROUP BY clause and contains nonaggregated column … incompatible with sql_mode=only_full_group_by

前端 未结 19 3040
灰色年华
灰色年华 2020-11-22 11:28

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          


        
相关标签:
19条回答
  • 2020-11-22 12:05

    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

    You can solve it by changing the sql mode with this command:

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

    and ... remember to reconnect the database!!!

    0 讨论(0)
提交回复
热议问题