jlrdw
5 months ago
892
1
Guides

Turn off only_full_group_by for just one query (Guide)

Posted 5 months ago by jlrdw

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

// then run your query

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

Please sign in or create an account to participate in this conversation.