title: CodeIgniter: LEFT JOIN in $this->db->query returns a database error
body: <p>I need to exclude second query (data from a second table) similar to MINUS. But since MySQL doesn't support MINUS, I decided to go with LEFT JOIN. However it gives me a database error.</p>
  
  <p><img src="https://i.stack.imgur.com/ZhTXg.png" alt="enter image description here"></p>
  
  <p><strong>Model</strong></p>
  
  <pre><code>function searchRooms($room_type, $start_date, $end_date) {
  // Line 6 is the below one:
      $query = $this-&gt;db-&gt;query(
          "SELECT     room_number
          FROM        rooms
          WHERE       room_type = '$room_type'
          ORDER BY    room_number ASC
  
          LEFT JOIN
  
          SELECT      room_number
          FROM        new_reservation
          WHERE       start_date &gt;= '$start_date'
          AND         end_date &lt;= '$end_date'
          ORDER BY    room_number ASC
          ");
      return $query-&gt;result();
  
  }
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>function search() {
          $room_type = $this-&gt;input-&gt;post('room_type');
          $start_date = $this-&gt;input-&gt;post('start_date');
          $end_date = $this-&gt;input-&gt;post('end_date');
          $this-&gt;reservations_model-&gt;searchRooms($room_type, $start_date, $end_date);
  
          $this-&gt;index();
  }
  </code></pre>