List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:October 11 2004 6:40pm
Subject:Re: alias not allowed in WHERE clause?
View as plain text  
At 11:32 -0700 10/11/04, Nathan Clark wrote:
>SELECT city, state, SQRT( POWER( (
>latitude - 39.039200
>), 2 ) + POWER( (
>longitude + 95.689508
>), 2 ) ) AS distance
>FROM geographics
>WHERE distance <1
>ORDER BY distance
>LIMIT 10;
>
>Returns:
>#1054 - Unknown column 'distance' in 'where clause'
>
>Are alias not allowed in WHERE clauses?

How could they be?  The WHERE clause determines which rows to select.
Aliases are defined for columns from the rows that have been selected.

>
>I am able to replace the alias with the entire math function, and it
>works as desired.  However, I do not like the heaviness/repetiveness
>of the query.


-- 
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com
Thread
alias not allowed in WHERE clause?Nathan Clark11 Oct
  • Re: alias not allowed in WHERE clause?Paul DuBois11 Oct
    • Re: alias not allowed in WHERE clause?Morten Egan11 Oct
      • Re: alias not allowed in WHERE clause?John McCaskey12 Oct
  • Re: alias not allowed in WHERE clause?Harald Fuchs12 Oct