After laravel 5.3, MySQL strict mode is enabled by default ( strict
)
in
MySQL strict mode, and only is enabled_ FULL_ GROUP_ If the
group by field does not appear in the select statement, an error will be reported. If the strict mode is turned off, no error will be reported
The demo is as follows
public static function orders($phase) { return self::select(DB::raw("SUM(orders) as orders"),"type","users_id","name") ->groupBy("type","name") ->where("phase",$phase) ->get(); }
The following errors will appear. Of course, the contents of the * sign are different
Syntax error or access violation: 1055 '***' isn't in GROUP BY
Solutions
laravel
the reason for the above error is sql_ For problems caused by mode
setting, modify strict = > in
to turn off strict mode: config/database. PHP
configuration file; False
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'engine' => null, ],
Similar Posts:
- [Solved] Laravel Groupby error: laravel which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
- Laravel uses group by to report errors [How to Solve]
- When laravel is uploaded to the server, whoops, looks like something went wrong appears
- [Solved] SELECT list is not in GROUP BY clause and contains nonaggregated
- [Solved] MYSQL Command gruop by Error: this is incompatible with sql_mode=only_full_group_by
- [Solved] MYSQL8 group by Error: Cause: java.sql.SQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY
- SELECT list is not in GROUP BY clause and contains nonaggregated column
- Mysql Error: 1140 – In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column ‘a.store’; this is incompatible with sql_mode=only_full_group_by
- How to Solve Client does not support authentication protocol requested by server; Consider upgrading MySQL
- [Err] 1055 – Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated c