Code: Select all
table users:
id name
1 aaa
2 bbb
3 ccc
Code: Select all
eid user_id course_id course type
1 1 12 graduation
2 1 13 post_graduation
3 2 18 graduation
4 2 20 post_graduation
Code: Select all
user_id eid course_type
2 4 post_graduation
1 2 post_graduation
Code: Select all
$this->db->select('u.id as user_id,e.eid,e.course_type');
$this->db->from('users u');
$this->db->join('education_details e','e.user_id=u.id','left');
$this->db->order_by('e.id','desc');
$this->db->group_by('e.user_id');
$this->db->get()->result();
Mobile version