Laravel模型按问题分组。我不知道该怎么称呼

时间:2019-07-17 13:14:26

标签: php laravel migration

$subject_list = ClassSubjectList::groupBy('class','group')->get();

上面的代码行给了我我不明白的错误

错误消息:

  

SQLSTATE [42000]:语法错误或访问冲突:1055'bncd_db.class_subject_lists.id'不在GROUP BY中(SQL:从class_subject_lists中按class,{{1 }})

ClassSubjectList模型

group

表结构

class ClassSubjectList extends Model
{
   protected $table = 'class_subject_lists';

   protected $fillable = [
       'class','group','subject'
   ];
}

功能

Schema::create('class_subject_lists', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->string('class');
    $table->string('group')->nullable();
    $table->string('subject');
    $table->timestamps();
});

0 个答案:

没有答案