Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable ONLY_FULL_GROUP_BY in MySQL

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

like image 662
BDesh Avatar asked Apr 14 '19 11:04

BDesh


People also ask

What is Only_full_group_by in MySQL?

If ONLY_FULL_GROUP_BY is disabled, a MySQL extension to the standard SQL use of GROUP BY permits the select list, HAVING condition, or ORDER BY list to refer to nonaggregated columns even if the columns are not functionally dependent on GROUP BY columns. This causes MySQL to accept the preceding query.

How do I enable strict mode in MySQL?

To turn it ON, add STRICT_TRANS_TABLES on that line like this: sql_mode=STRICT_TRANS_TABLES .

How do I change SQL mode in MySQL?

To change the SQL mode at runtime, set the global or session sql_mode system variable using a SET statement: SET GLOBAL sql_mode = 'modes'; SET SESSION sql_mode = 'modes'; Setting the GLOBAL variable requires the SUPER privilege and affects the operation of all clients that connect from that time on.


1 Answers

To avoid problems with other configurations, use CONCAT:

SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode, ',ONLY_FULL_GROUP_BY'));
like image 117
Nico Antonelli Avatar answered Oct 04 '22 21:10

Nico Antonelli