执行SQL:
SELECT login_name,login_ip,sex FROM tank_admin GROUP BY login_name ;
时抛出异常。
Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated
column 'loser.tank_admin.login_ip' which is not functionally dependent on columns in GROUP BY clause;
this is incompatible with sql_mode=only_full_group_by
这个sql语句违背了sql_mode=only_full_group_by 。
解决办法:
1.用sql查询:
select @@global.sql_mode
结果显示:
ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
2.去掉ONLY_FULL_GROUP_BY,重新设置值。
set
@@global.sql_mode=
'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';