在laravel 5
時嘗試執行SQL命令其我不明白上phpmyadmin
任何錯誤:在laravel雄辯越來越語法錯誤或訪問衝突錯誤
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'
與此查詢爲:
$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();
我得到這個錯誤:
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
的可能的複製[MySQL的#1140 - 組列混合](https://stackoverflow.com/questions/1244169/mysql-1140-混合組列) – Maraboc
下面是爲你工作嗎?我的意思是添加groupBy? – Maraboc
@Maraboc不,它不適合我 –