[eluser]datguru[/eluser]
Hi there, I'm trying to select the greatest ID out of my database but it is not a normal select greatest query.
Here is the SQL:
Code:
$this->db->select("*");
$this->db->from('progress');
$this->db->where('completed', 1);
$this->db->where_in('instituion_id', $inst_id);
$this->db->order_by('steps_id', 'desc');
$this->db->join('institutions', 'institutions.id = progress.institution_id', 'right');
$this->db->limit(sizeof($inst_id));
$data['instname'] = $this->db->get();
So what I'm trying to do is join the institution table since it contains the name of the institution to the progress table since it contains the highest step. This query almost works apart from it selects multiple steps from the institutions and not just one step for each institution. Is there a way to "select ONLY the highest step id for each institution"?
Thanks for your time.