Home >Database >Mysql Tutorial >How to Fix MySQL\'s Only_full_group_by Error in Laravel Eloquent?
Resolving MySQL's Only-Full-Group-By Problem in Laravel Eloquent
When executing Laravel Eloquent queries, you may encounter the error "Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column..." indicating that MySQL's strict mode (sql_mode=only_full_group_by) is enabled.
To resolve this issue, you can disable MySQL's strict mode in your database connection settings:
'connections' => [ 'mysql' => [ // Behave like MySQL 5.6 'strict' => false, // Behave like MySQL 5.7 'strict' => true, ] ]
This will allow you to execute queries without the need to explicitly aggregate non-grouped columns. Additionally, you can explore other configuration settings mentioned in Matt Stauffer's blog post for further customization.
The above is the detailed content of How to Fix MySQL's Only_full_group_by Error in Laravel Eloquent?. For more information, please follow other related articles on the PHP Chinese website!