$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();
});