Group by not working - Laravel

Parth Vora picture Parth Vora · Jan 10, 2017 · Viewed 40k times · Source

I'm not able to run this simple query in Laravel 5.3

$top_performers = DB::table('pom_votes')
        ->groupBy('performer_id')
        ->get();

It gives me:

SQLSTATE[42000]: Syntax error or access violation: 1055 'assessment_system.pom_votes.id' isn't in GROUP BY (SQL: select * from `pom_votes` group by `performer_id`)

However if I copy raw query from the error and fire directly in PhpMyAdmin, it works fine.

I have already checked this:

https://laravel.com/docs/5.3/queries#ordering-grouping-limit-and-offset

Any help would be appricaited.

Thanks,

Parth Vora

Answer

Md.Jewel Mia picture Md.Jewel Mia · Jan 10, 2017

Edit your applications's database config file config/database.php

In mysql array, set strict => false to disable MySQL's strict mode