Syntax error or access violation: 1055 isn't in GROUP BY in Laravel | Laravel : Syntax error or access violation: 1055 Error

This error is not because of the Laravel actually. This is MySQL error and which comes if you have ONLY_FULL_GROUP_BY inside the SQL_MODE variable in your DB.

Of course you can handle it at MySQL level by removing ONLY_FULL_GROUP_BY from you SQL_MODE.

But Laravel also provides the functionality to handle this error.

check your config/database.php And check if inside the mysql settings there is one that is like:

If you turn 'strict' to false will resolve you issue like;



But if you are turning 'strict' to false will remove all these below SQL modes.

1) ONLY_FULL_GROUP_BY
2) STRICT_TRANS_TABLES
3) NO_ZERO_IN_DATE
4) NO_ZERO_DATE
5) ERROR_FOR_DIVISION_BY_ZERO
6) NO_AUTO_CREATE_USER
7) NO_ENGINE_SUBSTITUTION

And the issue we are facing is just because of ONLY_FULL_GROUP_BY SQL_MODE.

So I think turning off all the SQL_MODES is not a better approach yaah it can be quick fix.

Laravel provides a beautiful feature and that is we also can define our SQL modes with every database connection in out configuration file.

Like if we need 2 SQL_MODE then we can define it like:

So we can set the SQL_MODE in our configuration file 'config/database.php' like:



So here I just removed ONLY_FULL_GROUP_BY SQL_MODE from the modes list which will also resolve the access violation of group By.

And I will keep:

Share This:

Leave a Reply

Your email address will not be published. Required fields are marked *