I am using CodeIgniter. I have a two table and I am joining than using join.

members

```
 member_id | name  | email       
        1  |lkjh   |asd@gmail.com
        2  |jjlk   |qwe@gmail.com
        3  |sfsd   |gfh@gmail.com
        4  |qqwe   |tyut@gmail.com

```

member\_details

```
id | member_id |game   | year     | date_of_added
1  |   1       |lkjh   |2018-2019 | 14-02-2019 02:26:30
2  |   1       |jjlk   |2019-2020 | 14-02-2019 03:30:20
3  |   2       |sfsd   |2018-2019 | 14-02-2019 04:00:40
4  |   3       |qqwe   |2018-2019 | 14-02-2019 04:30:20
5  |   2       |sfsd   |2019-2020 | 14-02-2019 05:45:30

```

Now my issue is, I have to display all the records from the member\_details but I have to display the last records of the member\_id.

So my expected output from member\_details table is,

```
   1   |jjlk   |2019-2020 | 14-02-2019 03:30:20
   3   |qqwe   |2018-2019 | 14-02-2019 04:30:20
   2   |sfsd   |2019-2020 | 14-02-2019 05:45:30

```

I tried below code

```
$get_s_member = array('members.is_Approved'=>1,'members.is_status'=>1);
    $this->db->select('*');
    $this->db->from('members'); 
    $this->db->join('membership_details', 'members.member_id = membership_details.member_id','LEFT');
    $this->db->where($get_s_member);
    $this->db->group_by('membership_details.member_id'); 
    $this->db->order_by('membership_details.date_of_added','DESC');
     $this->db->limit('1');
    $query = $this->db->get();
    $res   = $query->result();
 return $res;

```