Reputation: 168
I have disabled ONLY_FULL_GROUP_BY
by using SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
. Now I want to restore the default settings.
Is it possible to enable the ONLY_FULL_GROUP_BY
in MySQL again?
Thanks in advance
Upvotes: 9
Views: 20220
Reputation: 212
To avoid problems with other configurations, use CONCAT:
SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode, ',ONLY_FULL_GROUP_BY'));
Upvotes: 18
Reputation: 17545
If you are using Laravel, you could do this on runtime instead of making a global setting
//disable ONLY_FULL_GROUP_BY
DB::statement("SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));");
//Your SQL goes here - The one throwing the error (:
//re-able ONLY_FULL_GROUP_BY
DB::statement("SET sql_mode=(SELECT CONCAT(@@sql_mode, ',ONLY_FULL_GROUP_BY'));");
Upvotes: 5