title: Getting unknown column error when using 'as' in mysql statement
body: <p>I have this MySQL statement:</p>
  
  <pre><code>SELECT a.id, a.`from member_id`, a.`to member_id`, IF(a.`from member_id`=1, a.`to member_id`, a.`from member_id`) as other_id, a.text, MAX(a.`date sent`) as `date sent`
  FROM message a
  JOIN members m on other_id=m.id
  WHERE (a.`from member_id`=1 OR a.`to member_id`=1) AND a.active=1
  GROUP BY other_id
  ORDER BY other_id DESC, `date sent` DESC
  </code></pre>
  
  <p>but I am getting the error:</p>
  
  <pre><code>#1054 - Unknown column 'other_id' in 'on clause' 
  </code></pre>
  
  <p>I am creating that column using the <code>as</code> key. Does anyone know whats wrong here?</p>
  
  <p>Thanks.</p>