laravel Syntax error or access violation: 1463 Non-grouping field 'total_views' is used in HAVING

$list = DB::table('posts')
        ->groupBy('user_id')
        ->selectRaw('user_id,sum(views) as total_views')
        ->having('total_views' , '>=' , 10)
        ->get();

執行後報錯

Check in the config/database.php file in the mysql conection that the strict is false:

'strict' => false, // 更新爲false,就能執行了

If is true, put in false.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章