You may use Alias's if you use HAVING instead of WHERE this is one of the defined difrerences between the two clauses. Having is also slower and will not be optimized, but if you are placing a complex function like this in your where you obviously aren't expecting great speed.
John On Mon, 2004-10-11 at 23:51 +0200, Morten Egan wrote: > Well, it might not be SQL standard, but most databases out there allow > you to use the alias in your where clauses. It helps make the sql more > readable, and it shouldn't be that hard to add this feature to the > parser, so it can translate that alias back to the original row-source > selection, during parse time. > > /morten > > Paul DuBois wrote: > > > 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. > > > > > > > > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]