title: mySQL reusing calculated value in WHERE clause
body: <pre><code>SELECT 
    table1.a,
    table1.b, 
    (SELECT b 
    FROM table2 
    WHERE table2.b - table1.a &lt; 10 
    LIMIT 0,1) as test
  FROM table1 
  WHERE table1.b &lt; test;
  </code></pre>
  
  <p>I'm trying to use the result received in the SELECT "variable" <strong>test</strong> in the WHERE part of my query.</p>
  
  <p>Any idea how to do that without having to redo the calculation or whatsoever in the WHERE again? That's how i managed to make it work so far.</p>