title: Multiple select query with single where clause?
body: <p>I am creating a messaging system. In which there are two type of user admin and user.<br>
  Admin can send message to all user and user can send message to admin.<br>
  I am trying to fetch,</p>
  
  <pre><code>$this-&gt;db-&gt;select("user_from,count(user_from)as total");
  $this-&gt;db-&gt;from("messages");
  $this-&gt;db-&gt;group_by("user_from");
  $query = $this-&gt;db-&gt;get();
  return $query-&gt;result_array();
  
  $this-&gt;db-&gt;select("*");
  $this-&gt;db-&gt;from("messages");
  $this-&gt;db-&gt;where("user_to","admin");
  $query = $this-&gt;db-&gt;get();
  return $query-&gt;result_array();
  </code></pre>
  
  <p>In single both the query work correctly.<br>
  I want to include both query in one.<br>
  I want to run multiple select query using single where clause which show the last message send by user to admin.<br>
  can anyone give me any idea?</p>
  
  <p><a href="https://i.stack.imgur.com/207u8.png" rel="nofollow noreferrer">table screenshot</a>
  <a href="https://i.stack.imgur.com/n3OOy.png" rel="nofollow noreferrer">model code</a></p>