错误:
SQLSTATE [42000]:语法错误或访问冲突:1064 SQL语法中有错误;检查与您的MariaDB服务器版本对应的手册,以便在'&& product_price
>附近使用正确的语法?'在第1行(SQL:select * from table_products
where && product_price
> 0)
我的代码:
public function faq(Request $request) {
$pro = Product::all();
$p_1 = Product::where('product_price', '>', 0,'&&', 'product_price','<', 250)->get();
return view('fontend.errors.faq', compact('pro', 'p_1'));
}
您可以在查询中添加另一个where()
以应用过滤器
$p_1 = Product::where('product_price', '>', 0)
->where('product_price','<', 250)
->get();
这会产生一个类似的查询
select * from table_products where product_price > 0 and product_price < 250
或者你可以使用->whereBetween()
$p_1 = Product::whereBetween('product_price', [0, 250])
->get();