title: Unknown column in where clause, but columns is specified in select
body: <p>I am using the following query </p>
  
  <pre><code>SELECT COALESCE(curr_bid, start_bid) AS `bid`, `lot`.*, (SELECT COUNT(id) from bid where lot_id=lot.id) as bids_count FROM `lot` LEFT JOIN (SELECT `lot_step`.`id`, `lot_step`.`lot_id`, max(amount) as curr_bid FROM `lot_step` GROUP BY `lot_step`.`lot_id`) `ls` ON lot.id = ls.lot_id  WHERE ((`bid` &gt;= '100') AND (`bid` &lt;= '100000000'))
  </code></pre>
  
  <p>But I always get <code>Unknown column 'bid' in 'where clause'</code>. Not sure how can this happen, because I specified the column after SELECT</p>