phpmysqllaravelmysql-error-1055

Group by query in in laravel 5.3


I have fired this query:

$articleList = \DB::table(config('backend.article_table'))
                ->leftjoin(config('access.users_table'), config('access.users_table') . '.id', '=', config('backend.article_table') . '.created_by')
                ->leftjoin(config('backend.article_specialization_table'), config('backend.article_specialization_table') . '.article_id', '=', config('backend.article_table') . '.id')
                ->leftjoin(config('backend.specialization_table'), config('backend.specialization_table') . '.id', '=', config('backend.article_specialization_table') . '.specialization_id')
                ->select(config('backend.article_table') . '.*', config('access.users_table') . '.name', config('access.users_table') . '.avatar', \DB::raw('group_concat(' . config('backend.specialization_table') . '.name) specialization'))
                ->whereRaw($appendWhr)
                ->whereRaw($appendPermission)
                ->groupBy(config('backend.article_table') . '.id')
                ->offset($offset)
                ->limit($pageLimit)
                ->orderBy(config('backend.article_table') . '.id', 'desc')
                ->get();

but I got the following error:

PDOException in Connection.php line 332: SQLSTATE[42000]: Syntax error or access violation 1055 'baseproject_new.articles.user_id' isn't in GROUP BY

PDOException in Connection.php line 332: SQLSTATE[42000]: Syntax error or access violation 1055 'baseproject_new.articles.user_id' isn't in GROUP BY

enter image description here

When run the query in mysql I got the result, but when I run the page I got the error. When I use the same query in laravel it will give me the result, but here in laravel 5.3 I got this error. How can I solve this?


Solution

  • You just need to change the value of "strict" to "false" in config/database