title: Using column alias in WHERE clause of MySQL query produces an error
body: <p>The query I'm running is as follows, however I'm getting this error:</p>
  
  <blockquote>
    <p>#1054 - Unknown column 'guaranteed_postcode' in 'IN/ALL/ANY subquery'</p>
  </blockquote>
  
  <pre><code>SELECT `users`.`first_name`, `users`.`last_name`, `users`.`email`,
  SUBSTRING(`locations`.`raw`,-6,4) AS `guaranteed_postcode`
  FROM `users` LEFT OUTER JOIN `locations`
  ON `users`.`id` = `locations`.`user_id`
  WHERE `guaranteed_postcode` NOT IN #this is where the fake col is being used
  (
   SELECT `postcode` FROM `postcodes` WHERE `region` IN
   (
    'australia'
   )
  )
  </code></pre>
  
  <p>My question is: why am I unable to use a fake column in the where clause of the same DB query?</p>