title: codeigniter join from 2nd table id with 3rd table id multi rows
body: <p>I want to join multiple tables, as in my picture:
  <a href="https://i.stack.imgur.com/yAr5o.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yAr5o.png" alt="enter image description here"></a></p>
  
  <p>Here is my code:</p>
  
  <pre><code>$this-&gt;db-&gt;select('
    pt2.turl as `p_img`,
    p.title as `p_title`,
    p.text as `p_text`,
    p.create as `p_date`,
    pt3.turl as `c_img`,
    u.name as `c_name`,
    c.text as `c_text`,      
    c.create as `c_date`
  ');
  
  $this-&gt;db-&gt;from('posts as p, users as u, photos as pt2, photos as pt3');    
  $this-&gt;db-&gt;join('comments as c', 'p.id=c.pid AND u.id=c.uid');
  $this-&gt;db-&gt;join('posts as p2', 'p2.pid=pt2.id', 'rihgt');
  $this-&gt;db-&gt;join('users as u2', 'u2.photoid=pt3.id', 'right');
  $this-&gt;db-&gt;order_by('c.id', 'DESC');
  $this-&gt;db-&gt;limit('7');
  $qry = $this-&gt;db-&gt;get();
  return $qry-&gt;result();
  </code></pre>