title: How to use sub-query result twice in the query?
body: <p>I have this query:</p>
  
  <pre><code>UPDATE QandA SET accepted = IF ( id &lt;&gt; :answer_id, 0, 1 )
    WHERE col1 = ( SELECT related FROM QandA WHERE id = :answer_id ) AND
          col2 = ( SELECT related FROM QandA WHERE id = :answer_id )
  </code></pre>
  
  <p>As you see there is two identical sub-queries. How can I write that sub-query once and use its result twice?</p>