jlrdw's avatar
Level 75

Turn off only_full_group_by for just one query (Guide)

I see many questions come up with the error:

SELECT list is not in GROUP BY clause and contains nonaggregated column .......

Many answers are telling the poster to change strict mode from true to false in the database config file.

But you can just do this for one query only by adding before the query:

config()->set('database.connections.your_connection.strict', false);

// change your_connection to actual connection name.

// then run your query

For example If the connection you need it on is mysql then:

config()->set('database.connections.mysql.strict', false);

That way if only needed for one query no need to change it in config/database.php

0 likes
1 reply
bugsysha's avatar

It would be nice to have vote powered guides.

2 likes

Please or to participate in this conversation.