0

如何在 Laravel 中使用这个查询?

SELECT * FROM table WHERE category = 1 AND item1 < 3 OR item2 < 3 OR item3 < 3

我试过这样

Items::where('category', $category)->where('item1', '<', '3')->where('item2', '<', '3')->where('item3', '<', '3')->count();

像这样

Items::where('category', $category)->where('item1', '<', '3')->orWhere('item2', '<', '3')->orWhere('item3', '<', '3')->count();

但没有任何效果。在一个类别中,我有两种产品,3 项。每个项目都有一些价值。我需要检查每个项目的价值并计算它们。我只想显示价值小于 3 的项目。在这个例子中,它应该是 2/2,这意味着 2 个产品有 2 个价值小于 3 的项目。

4

0 回答 0