Home >Backend Development >PHP Tutorial >How to Fix Laravel's 'Syntax error or access violation: 1055 Error' with WhereIn and GroupBy?

How to Fix Laravel's 'Syntax error or access violation: 1055 Error' with WhereIn and GroupBy?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-12-10 15:33:09979browse

How to Fix Laravel's

Troubleshooting Laravel "Syntax error or access violation: 1055 Error" when Using WhereIn and GroupBy

In Laravel, combining WhereIn and GroupBy in a single query can sometimes lead to the "Syntax error or access violation: 1055 Error." This is because of a MySQL configuration setting called strict.

Short Answer

In the config/database.php file, you can disable all strict options by setting:

'mysql' => [
    'strict' => false
]

Detailed Answer

Instead of disabling all strict options, you can also selectively allow grouping by one column by adding the ONLY_FULL_GROUP_BY mode:

'mysql' => [
    ...
    'strict' => true,
    'modes' => [
        'ONLY_FULL_GROUP_BY'
    ]
]

For a complete discussion on this issue, refer to the following answer:

[GitHub Issue: "Syntax error or access violation: 1055 Error" when Combining WhereIn and GroupBy](https://github.com/laravel/framework/issues/2981)

The above is the detailed content of How to Fix Laravel's 'Syntax error or access violation: 1055 Error' with WhereIn and GroupBy?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn