将价格范围值与产品表,产品常规价格和产品销售价格的两列进行比较

问题描述 投票:0回答:1

我在表名中有两列分别是产品正常价格和产品销售价格。我必须根据用户给定的价格范围搜索最小价格产品。从单个列中搜索最低价格很容易,但是从两个列中搜索最低价格似乎都很困难。

$products = $products->whereBetween(['ecommerce_sku.regular_price','ecommerce_sku.sale_price'], [$minPrice, $maxPrice]);
php database laravel
1个回答
0
投票

您可以将常规价格和销售价格分开。

$products = $products
->whereBetween('ecommerce_sku.sale_price', [$minPrice, $maxPrice])
->whereBetween('ecommerce_sku.regular_price', [$minPrice, $maxPrice]); 
© www.soinside.com 2019 - 2024. All rights reserved.