How to get minimum value in mysql table column using Codeigniter

Codeigniter provides select_min method to get minimum value in mysql table column. Writes a “SELECT MIN(field)” portion for your query. As with select_max(), You can optionally include a second parameter to rename the resulting field.

Let’s create a select_min method in codeigniter

$this->db->select_min('amount');
$result = $this->db->get('tbl_product')->row();  
return $result->amount;

Leave a Reply

Your email address will not be published. Required fields are marked *