I am creating a messaging system. In which there are two type of user admin and user.
Admin can send message to all user and user can send message to admin.
I am trying to fetch,
$this->db->select("user_from,count(user_from)as total");
$this->db->from("messages");
$this->db->group_by("user_from");
$query = $this->db->get();
return $query->result_array();
$this->db->select("*");
$this->db->from("messages");
$this->db->where("user_to","admin");
$query = $this->db->get();
return $query->result_array();
In single both the query work correctly.
I want to include both query in one.
I want to run multiple select query using single where clause which show the last message send by user to admin.
can anyone give me any idea?