In article <[EMAIL PROTECTED]>, Morten Egan <[EMAIL PROTECTED]> writes:
> 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. At least PostgreSQL does not allow that. However, there's a SQL standard solution: derived tables. SELECT name, distance FROM ( SELECT name, SQRT(POWER((lat - 39.039200), 2) + POWER((lon + 95.689508), 2)) AS distance FROM cities ) AS x WHERE distance < 1 ORDER BY distance LIMIT 10; This works in MySQL 4.1.x, and a good query planner would be able to optimize it properly. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]