title: Write union query in codeigniter style
body: <p>How can I write the following query in Codeigniter style.</p>
  
  <pre><code>SELECT COUNT(`id`) AS reccount
    FROM 
      (SELECT `id` FROM table1 
       WHERE tid= '101' AND `status` =  1
       UNION ALL
      SELECT `id` FROM table2 
       WHERE tid= '101' AND `status` =  1
       UNION ALL
      SELECT `id` FROM table3
       WHERE tid= '101' AND `status` =  1) t
  </code></pre>
  
  <p>I have used the following way to execute it.</p>
  
  <p>Is it the only correct way or do you have any suggestion to improve it?</p>
  
  <pre><code> $q = $this-&gt;db-&gt;query(SELECT COUNT(`id`) AS reccount
                          FROM 
                          (SELECT `id` FROM table1 
                           WHERE tid= '101' AND `status` =  1
                           UNION ALL
                           SELECT `id` FROM table2 
                           WHERE tid= '101' AND `status` =  1
                           UNION ALL
                           SELECT `id` FROM table3
                           WHERE tid= '101' AND `status` =  1) t ");
  </code></pre>