【问题标题】:How to add where between in the query?如何在查询中添加 where between?
【发布时间】:2019-12-28 21:50:06
【问题描述】:

在下面的查询中,我只需要获取特定日期之间的那些产品的总和如何在查询之间添加查询以获取总和?

 $order =  Order::with('customer','product')->select('orders.id', 'orders.customer_id', 'orderdets.product_id', DB::raw('SUM(orderdets.quantity) as sum'))
    ->leftJoin('orderdets', 'orders.id', '=', 'orderdets.order_id')
    ->where('product_id', $scheme[0]->product_id)
    ->groupBy('orders.customer_id')
    ->get();

【问题讨论】:

  • 不确定这是哪种语言,但我认为您可以再添加 2 个 where 子句。或者看看有没有between方法

标签: php database laravel


【解决方案1】:

你可以使用类似的东西

$users = DB::table('users')
           ->whereBetween('votes', [1, 100])
           ->get();

查看https://laravel.com/docs/6.x/queries 了解使用 where 子句的任何其他方式

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-07-02
    • 1970-01-01
    • 1970-01-01
    • 2012-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多