Chcete-li tento problém vyřešit, musíte zadat požadované sloupce v seznamu select a group by clause
$search_alls=DB::table('a16s as A')
->select('A.id','A.name')
->addSelect(DB::raw('SUM(CASE WHEN B.approve = 1 ELSE 0 END) as Yshow'))
->leftjoin('a16s_likes as B', function($join) {
$join->on('A.id', '=', 'B.p_id');
})
->groupBy('A.id')
->groupBy('A.name');
->get();
12.19.3 MySQL Handling of GROUP BY
Podle dokumentů