Solution to the ONLY_FULL_GROUP_BY problem of mysql

You must have encountered a problem similar to this when you grouped the data table:
select username, age from users group by age;
then mysql reported an error:
ERROR 1055 (42000): Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'mytest.users.username' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
roughly means that you must group the username and age you want to query Only then.... So you have to
select username, age from users group by age, username; in order to pass the compilation, but this will lose the original meaning of the group,
so we change the original sql_mode= by changing sql_mode=''; 'ONLY_FULL_GROUP_BY'; this will do

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326687494&siteId=291194637