-1

を使用してデータベースから列のゼロではなく最小値を取得したいCodeigniter

これは私が使用している現在のコードですが、列の値も0であるため、0が返されます。

$this->db->select_min('saleprice');
        $this->db->join('category_products', 'category_products.product_id=products.id', 'right');
        $this->db->where('category_products.category_id', $cat_id);
        $this->db->where('products.enabled',1);
        return  $this->db->get('products')->row_array();

0ではなく最小値を取得する方法を教えてください

4

1 に答える 1

3

whereこのような条件を追加してみてください

$this->db->where('saleprice >','0');

次に、クエリは次のようになります

$this->db->select_min('saleprice');
$this->db->join('category_products', 'category_products.product_id=products.id', 'right');
$this->db->where('category_products.category_id', $cat_id);
$this->db->where('products.enabled',1);
$this->db->where('saleprice >','0');  //Add this 

!=のように使用することもできます

$this->db->where('saleprice !=','0');     
于 2013-08-27T07:08:13.010 に答える