MySQL Error: SELECT list is not in GROUP BY clause

前端 未结 4 2102
有刺的猬
有刺的猬 2020-11-29 14:18

I have a problem with my query and mysql throws the following error:

#1055 - Expression #66 of SELECT list is not in GROUP BY clause and 
contai         


        
4条回答
  •  心在旅途
    2020-11-29 14:45

    Are you trying to do an ORDER BY? The GROUP BY clause attempts to return one row for each distinct value in the column in the GROUP BY clause, unless you add more columns to the clause. The error is being thrown because you have other non-aggregated columns that are not being included in the clause - aggregated columns would be something like MAX(p.products_id) or SUM(p.products_price). In your query, there are multiple rows with the same p.product_price and different s.status values, so the GROUP BY isn't meaningful.

    MySQL Group By handling: https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html Aggregate functions: http://dev.mysql.com/doc/refman/5.7/en/group-by-functions.html

提交回复
热议问题