From: "Alvaro Cobo" <[EMAIL PROTECTED]>
To: <mysql@lists.mysql.com>
Sent: Sunday, June 12, 2005 8:17 AM
Subject: Re-use a result field into a query


> Is it possible to refer into a query to a result field from the same
query?.
> For example: a query which uses the field name of a result (alias) to
create
> a new field:

A quick look in the online manual at
http://dev.mysql.com/doc/mysql/en/select.html tells us:

----------------
A select_expr can be given an alias using AS alias_name. The alias is used
as the expression's column name and can be used in GROUP BY, ORDER BY, or
HAVING clauses.

(...)It is not allowable to use a column alias in a WHERE clause, because
the column value might not yet be determined when the WHERE clause is
executed. See Section A.5.4, "Problems with Column Aliases".
--------------

So, you can only refer to an alias in the GROUP BY, ORDER BY or HAVING
section of a query.

Regards, Jigal.


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to