title: MySQL condition on the COALESCE syntax
body: <p>I have a query composing of COALESCE syntax. the COALESCE syntax simply find the Audited Date of a file. On my WHERE statement, I just want to output the Audited File base from the <code>AuditDate</code> alias field but i doesn't work. Here is my query.</p>
  
  <pre><code>SELECT COALESCE(qua.starttime, prd.starttime) AS `AuditDate`,
         prd.employeeno AS `EmployeeNo`,
         prd.starttime AS `StartTime`,
         prd.endtime AS `EndTime`
    FROM production prd
    LEFT JOIN qualityaudit qua
      ON prd.id=qua.id
   WHERE `AuditDate` BETWEEN '2011-10-01 00:00:00' AND '2011-10-01 23:59:59';
  </code></pre>
  
  <p>Can anyone help me on how should I get this query correct?</p>