title: Joomla 3.1 JDatabase Union Query
body: <p>Would anyone be able to show how to do a union with the jDatabase <code>query</code> object?</p>
  
  <p>The functionality looks to be in Joomla, I just can't find any documentation with working examples...</p>
  
  <p>The query I'm wanting to achieve would normally look like this in plain text:</p>
  
  <pre><code>SELECT field1,field2 FROM `#__mycomponent_table1` WHERE field1 = 0
  UNION
  SELECT field1,field2 FROM `#__mycomponent_table2` WHERE field1 = 0
  </code></pre>
  
  <p>EDIT - I've tried this:</p>
  
  <pre><code>$db = $this-&gt;getDbo();
  $query = $db-&gt;getQuery(true);
  $query-&gt;union(array('SELECT field1,field2 FROM `#__mycomponent_table1` WHERE field1 = 0','SELECT field1,field2 FROM `#__mycomponent_table2` WHERE field1 = 0'));
  </code></pre>
  
  <p>Gives Me: </p>
  
  <blockquote>
    <p>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0, 15' at line 1 SQL= LIMIT 0, 15 SQL='</p>
  </blockquote>