samedi 22 juillet 2017

Laravel QueryException in Connection.php line 647: SQLSTATE[42000]: Syntax error or access violation

I was trying to run the following Query with Query builder.

$products = \DB::table('users')
            ->join('products','products.auth_id','users.id')
            ->leftjoin('buys','products.id','buys.product_id')
            ->select('products.*','users.avatar',DB::raw('COUNT(buys.product_id) as total_sells') ) 
            ->groupBy('products.id')               
            ->where('products.status','=','1')
            ->take(20)
            ->paginate(4);

Where in products.id could be there in buys table or not..

But i was getting following Error. I changed the database.php mysql array from strict = true to false.

QueryException in Connection.php line 647:
SQLSTATE[42000]: Syntax error or access violation: 1055 'cart.products.name' isn't in GROUP BY



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire