title: CodeIgniter database query with left and inner join
body: <p>i am  having troubles translating this database query </p>
  
  <pre><code> SELECT 'conversations','conversation_id',
  'conversations','conversation_subject',
  MAX('conversations_messages','message_date') AS 'conversation_last_reply'
  FROM 'conversations'
  LEFT JOIN 'conversations_messages' ON 'conversations'.'conversation_id' = 'conversations_messages'.'conversation_id'
  INNER JOIN 'conversations_members' ON 'conversations'.'conversation_id' = 'conversations_members'.'conversation_id'
  WHERE 'conversations_members', 'user_id' = $sender_id
  AND 'conversations_members','conversation_deleted' = 0
  GROUP BY 'conversations'.'conversation_id'
  ORDER BY 'conversation_last_reply'  DESC";
  </code></pre>
  
  <p>to codeignitor's active records . </p>
  
  <p>I have tried it this way </p>
  
  <pre><code>$this-&gt;db-&gt;select('conversation_id, conversation_subject');
  
      $this-&gt;db-&gt;get('conversations');
  
       $this-&gt;db-&gt;select_max('message_date', 'conversation_last_reply');
  
      $this-&gt;db-&gt;get('conversations_messsages');
     $this-&gt;db-&gt;from('conversations');
     ........
  </code></pre>
  
  <p>But i get stack at left  and inner join . So i tried it this way </p>
  
  <pre><code> $query = $this-&gt;db-&gt;query(
      SELECT 
            'conversations','conversation_id',
           'conversations','conversation_subject',
      MAX('conversations_messages','message_date') AS 'conversation_last_reply'
      FROM 'conversations'
      LEFT JOIN 'conversations_messages' ON 'conversations'.'conversation_id' = 'conversations_messages'.'conversation_id'
      INNER JOIN 'conversations_members' ON 'conversations'.'conversation_id' = 'conversations_members'.'conversation_id'
      WHERE 'conversations_members', 'user_id' = $sender_id
      AND 'conversations_members','conversation_deleted' = 0
      GROUP BY 'conversations'.'conversation_id'
      ORDER BY 'conversation_last_reply'  DESC"
          );
     return $query-&gt;result();
  </code></pre>
  
  <p>but there's errors everywhere.</p>