Welcome Guest, Not a member yet? Register   Sign In
DB Select Average
#1

[eluser]ShoeLace1291[/eluser]
How do I display just the average of the column with the select average function? This is my quuery:

Code:
$this->db->select_avg('price');
$this->db->where('restaurant', $restaurant->id);
$query = $this->db->get('menu_items');
#2

[eluser]WanWizard[/eluser]
Code:
$this->db->select_avg('price', 'price');
$this->db->where('restaurant', $restaurant->id);
$query = $this->db->get('menu_items');
$row = $query->row();
echo $row->price;




Theme © iAndrew 2016 - Forum software by © MyBB