mercredi 27 décembre 2017

Eloquent getting Syntax error or access violation error

in laravel 5 when in try to implementing this sql command which i don't get any error on phpmyadmin :

SELECT shoppings.*, sum(shoppings.ordering_count) 
FROM `shoppings` join products on products.id = shoppings.product_id 
where `shoppings`.`user_ordering_ip` = '127.0.0.1' 

with this query on laravel as:

$userShoppings = \DB::table('shoppings')
    ->join('products', 'shoppings.product_id', '=', 'products.id')
    ->select('*', \DB::raw('sum(shoppings.ordering_count)'))
    ->where('shoppings.user_ordering_ip', "'".request()->ip()."'")
    ->get();

i get this error:

SQLSTATE[42000]: Syntax error or access violation: 1140 Mixing of 
GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is 
illegal if there is no GROUP BY clause 



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2lg8P9v
via IFTTT

Aucun commentaire:

Enregistrer un commentaire