SELECT列表的表达式#29不在GROUP BY子句中,并且包含未聚合的列

时间:2019-05-31 13:54:10

标签: mysql centos

我正在使用GoDaddy VPS server,服务器设置完成后,我可以看到他们提供了MySql version 5.7。我在MySql查询中遇到以下错误,但是此查询在MySql 5.6

中运行良好

我有root access

错误-> Expression #29 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'sephecom_ecom.v2.secondary_colors' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

1 个答案:

答案 0 :(得分:0)

这不是版本问题,是配置问题

问题是您拥有SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY','')); 。这意味着您所有的选择列都必须在GROUP BY上,或者必须使用聚合函数(例如sum,avg,count等)。如果您想避免这种情况,可以通过

进行更改
#include<iostream>
using namespace std;
int main()
{
    char day;
    cout<<"Enter the day\n";
    cin>>day;
    switch(day)
    {
        case 'monday': cout<<"The next day is Tuesday";
                       break;
        case 'tuesday': cout<<"The next day is Wednesday";
                        break;
        case 'wednesday': cout<<"The next day is Thursday";
                       break;
        case 'thursday': cout<<"The next day is Friday";
                       break;
        case 'friday': cout<<"The next day is Saturday";
                       break;
        case 'saturday': cout<<"The next day is Sunday";
                       break;
        case 'sunday': cout<<"The next day is Monday";
                       break;
        default: cout<<"Day is invalid";
                        break;
    }

}'''

Errors from the terminal:
case label value has already appeared in this switch at line 12[14,14]  
case label value has already appeared in this switch at line 12[16,14]  
case label value has already appeared in this switch at line 12[22,14]

如果您按条件修改组,则查询中可能会得到奇怪的结果