Welcome Guest, Not a member yet? Register   Sign In
Order_by and Group_by Problem
#1

[eluser]Unknown[/eluser]
I have been struggling to select the latest record (message) of each user in my database.

I am joining two tables to generate the data I need to display: r_user and r_logbook


Code:
$this->db->join('r_logbook', 'r_logbook.user_id = r_user.id');
$this->db->group_by('r_user.id');
$this->db->order_by('r_logbook.id');
        
$query = $this->db->get('r_user');
        
return $query->result_array();

This obviously doesn't work, but is the best explanation of what I'd like to do. There must be another direction from which I could approach this, please let me know what you think or if you need any other info.




Theme © iAndrew 2016 - Forum software by © MyBB