这是我的Laravel查询:
$items = DashboardItem::distinct()->where('dashboard_id',$dashboard->id)->groupBy('type')->get();
我在此查询中遇到SQLSTATE[42000]: Syntax error or access violation: 1055
错误。
错误:
SQLSTATE[42000]: Syntax error or access violation: 1055 'testapp.dashboard_items.id' isn't in GROUP BY (SQL: select distinct * from `dashboard_items` where `dashboard_id` = 3 group by `type`)
Sql Query:
select distinct * from `dashboard_items` where `dashboard_id` = 3 group by `type`
但是当在PHPMyAdmin中运行这个SQL查询时,我得到了结果
答案 0 :(得分:0)
试试这个
$items = DB::table('dashboard_items')->where('dashboard_id',$dashboard->id)->groupBy('type')->distinct()->get();