这是我的查询,适用于所有旧版本。
$data = DB::table('applicant')
->groupBy('AppAffID')
->get();
我得到的错误是:
SQLSTATE[42000]: Syntax error or access violation: 1055 'comloant_loantreeAPI.applicant.AppID' isn't in GROUP BY (SQL: select * from `applicant` group by `AppAffID`)
我尝试过更改数据库:
我添加了严格的' => 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,
],
答案 0 :(得分:0)
使用groupBy
想要实现的目标是什么?如果您想对AppAffID
进行排序,则应使用orderBy
,而不是这样:
$data = DB::table('applicant')
->orderBy('AppAffID', 'desc') //can also use 'asc' for ascending
->get();