我正在使用代码点火器。我想要一个 where 子句来获取 totalQuantity 小于 alterQuantity 的产品。我在 select 子句中使用 sum 来获取 totalQuantity。
$this->db->select("products.id as productid, products.code, products.name, products.unit, products.cost, products.price, sum(whs_products.quantity) as totalQuantity, products.alert_quantity as alertQuantity")
->from('products')
->where('alertQuantity <=', 'totalQuantity')
->join('whs_products', 'whs_products.product_id=products.id', 'left')
->group_by("products.id");
$this->db->get();
我不确定如何获得所需的产品:(如果尝试过,请编辑
->where('alertQuantity <=', 'totalQuantity')
我得到了所有产品,但 ->where('alertQuantity <=', 'totalQuantity') 没有产品。