title: Store mysql subquery in a variable
body: <p>Is is possible to store a mysql subquery somehow, if it will be used again as a subquery?  Presumably this would produce cleaner code as well as save parsing overheads.</p>
  
  <p>For example in the following outer join</p>
  
  <pre><code>SELECT * FROM t1
  LEFT JOIN (SELECT * FROM t2 WHERE t2.foo=='bar') ON t1.id = t2.id
  UNION
  SELECT * FROM t1
  RIGHT JOIN (SELECT * FROM t2 WHERE t2.foo=='bar') ON t1.id = t2.id
  </code></pre>
  
  <p>It would be nice not to repeat <code>(SELECT * FROM t2 WHERE t2.foo=='bar')</code>.</p>