I'm trying to find how can i use MAX on laravel QueryBuilder or Eloquent join statement, for example:
$userShoppings = \DB::table('shoppings')
->join('products', 'shoppings.product_id', '=', 'products.id')
->select('shoppings.*', 'products.name','products.amount','max(shoppings.ordering_count)')
->where('shoppings.user_ordering_ip', request()->ip())
->get();
in this code i want to get max ordering_count from shoppings table on select method, but i get this error:
Column not found: 1054 Unknown column 'max(shoppings.ordering_count)' in 'field list'
could any body help me to solve this problem?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire