I have created a my application in laravel.my sql query is working fine.I'm bit struck with laravel query
select a.type from chart_table a left join color_codes b on a.type=b.type_id group by a.type
For the above query tried as
DB::table('chart_table')
->leftjoin('color_codes','color_codes.type_id','=','chart_table.type')
->whereIn('chart_table.user_name',$filter_username_details)
->orderBy('color_codes.id', 'asc')
->groupBy('chart_table.type')
->pluck('chart_table.type')
->toArray();
I'm getting the error as
SQLSTATE[42803]: Grouping error: 7 ERROR: column "color_codes.id" must appear in the GROUP BY clause or be used in an aggregate function<br />
LINE 1: ...le"."type" group by "chart_table"."type" order by "color_cod..
What I did wrong in my query
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire