Mysql 获取最小值但不为零(0)
我想使用Codeigniter从数据库中获取列的最小值,而不是零 这是我正在使用的当前代码,但它给了我0,因为列也有0值Mysql 获取最小值但不为零(0),mysql,codeigniter,min,Mysql,Codeigniter,Min,我想使用Codeigniter从数据库中获取列的最小值,而不是零 这是我正在使用的当前代码,但它给了我0,因为列也有0值 $this->db->select_min('saleprice'); $this->db->join('category_products', 'category_products.product_id=products.id', 'right'); $this->db->where('category_p
$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。请尝试添加这样的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');