title: How to union 2 SQL-query in Codeigniter?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2040655/union-query-with-codeigniters-active-record-pattern">UNION query with codeigniter&#39;s active record pattern</a>  </p>
  </blockquote>
  
  
  
  <p>I have the following code:</p>
  
  <pre><code>$language_id=$this-&gt;get_language_id($language_code);
  $english_id=$this-&gt;get_language_id('en');
  $query="SELECT e.label_value, t.user_id, t.votes, t.approved, t.language_value FROM labels e left outer join labels t on e.label_value=t.label_value WHERE e.language=$english_id and t.language=$language_id and (t.approved=1 or t.user_id=$user_id) and e.label_value in (select distinct label_value from labels  WHERE language=$english_id order by label_value limit $start_index, 30) order by e.label_value, t.votes";
  $query=$this-&gt;db-&gt;query($query);
  $data=$query-&gt;result_array();
  </code></pre>
  
  <p>But I have got the following error:</p>
  
  <pre><code>This version of MySQL doesn't yet support 'LIMIT &amp; IN/ALL/ANY/SOME subquery'
  </code></pre>
  
  <p>So, I need to do the folowoing part <code>"select distinct label_value from labels  WHERE language=$english_id order by label_value offset $start limit 30"</code> in another query. Please, help me, how can I do it using CodeIgniter?</p>
  
  <p>UPDATE:</p>
  
  <p>There are is table <code>labels</code></p>
  
  <pre><code>(label_value, language_value, language) - PK,
  user_id,
  timestamp,
  approved,
  votes
  </code></pre>
  
  <p>and I need to get all queries from this table (for example, it's name is t and e) with labels t.label_value, e.label_value (is exists), e.user_id, e.votes, e.timestamp where t.label_value=e.label_value(same label), t.language=45 (english language), e.language=24 (my language) and (e.user_id=121234 or e.approved=1). But I need all entries, and if (t.label_value!=e.label_value) I need to get this entry with NULL fields. </p>