我有這樣一個觀點:Laravel查詢訪問量
CREATE VIEW orders_sales AS
SELECT code, SUM(quantity) * SUM(sale_price) as product_total, shop_id
FROM `orders`
GROUP BY code, product_id
我想查詢它是這樣的:
$data = DB::table('orders_sales')->get();
我收到以下錯誤:
SQLSTATE[42000]: Syntax error or access violation: 1055 'pakishops2.orders.shop_id' isn't in GROUP BY (SQL: select * from
orders_sales
)
我能夠查詢它在phpmyadmin像select * from orders_sales但它不會查詢與Laravel。
編輯:
我已經改變了看法名view_saleorders,仍然沒有運氣現在
沒有訂單有shop_id字段嗎? – rahulsm
爲什麼你爲視圖和表保留相同的名稱?你可以改變它,並檢查 – rahulsm
我試過了,改名爲view_saleorders,沒有工作 –