gpt4 book ai didi

php - Laravel 查询 View

转载 作者:行者123 更新时间:2023-11-29 03:22:04 26 4
gpt4 key购买 nike

我的观点是这样的:

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 查询。

enter image description here

编辑:

我已将 View 名称更改为 view_saleorders,但还是不行

最佳答案

转到 config/database.php 文件并检查选项 strict 是否设置为 true。

将其设置为 false,您的查询将起作用。

关于php - Laravel 查询 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42606409/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com