title: Codeigniter : complex query with join and limit
body: <p>my query in codeigniter is like below,</p>
  
  <pre><code>$select = 'msg.*';
   $this-&gt;db-&gt;select($select, FALSE)
     -&gt;from(TBL_MESSAGES . ' as msg')
     -&gt;join(TBL_PRODUCT . ' as p', 'msg.ProductId=p.Id');        
     $query = $this-&gt;db-&gt;order_by('msg.Id', 'DESC')-&gt;get();
    if ($query-&gt;num_rows() &gt; 0) 
    {
        return $query-&gt;result_array();
    }
  </code></pre>
  
  <p>Here I want in result ,all messages of first 10 products ,
  but in above query if I place <code>limit</code> then It shows total 10 messages </p>
  
  <p>Can any one help me to how to place limit for above query ?</p>