title: conditional union-execute second query if first doesnt return rows
body: <p>I have a mysql query as below:</p>
  
  <pre><code>select m.field1, l.field2... l.fieldn
  from mytable m, logtable l
  where &lt;some conditions to join m and l&gt;
  
  union
  
  select m.field1, h.field2... h.fieldn
  from mytable m, loghistorytable h
  where &lt;some conditions to join m and h&gt;
  </code></pre>
  
  <p>Now since history table is quite huge and hits performance, i want to execute the second select from history only if the current log table doesn't return data. Can i modify the query somehow?</p>