Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 获取最小值但不为零(0)_Mysql_Codeigniter_Min - Fatal编程技术网

Mysql 获取最小值但不为零(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

我想使用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。请尝试添加这样的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');