Page 1 of 1

MySQL error : sql_mode=only_full_group_by

Posted: Wed May 30, 2018 9:56 am
by John Stanley
Hello,

I have this script where I'm used to doing a simple projection for a dynamic result but something goes wrong ; as i have this error :

1055 - Expression #5 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'mutuelle_bi.M.etat_bs' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

How may i modify my script, by the way, to solve this problem , given that I shouldn't modify any config file of my sql server . and i should only write scripts

Any Suggestions to fix this issue asap??

Re: MySQL error : sql_mode=only_full_group_by

Posted: Wed May 30, 2018 10:22 am
by Aaron
Hello,

You can try to disable the only_full_group_by setting in the MySQL configuration

Go to MySQL prompt and use the command listed below.

Code: Select all

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';
If you want to set these modes permanently then you need to edit your MySQL conf like below.

Code: Select all

sudo vi /etc/mysql/my.cnf
Scroll to the bottom of file and press 'i' to enter insert mode
Copy and paste

Code: Select all

[mysqld]
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION to the bottom of the file
esc to exit input mode
:wq to save and close vi editor.
sudo service mysql restart to restart MySQL.
Done!