Ver Mensaje Individual
  #2 (permalink)  
Antiguo 30/06/2009, 14:37
Avatar de deadlykyo
deadlykyo
 
Fecha de Ingreso: noviembre-2005
Ubicación: Cbba - Bolivia
Mensajes: 747
Antigüedad: 18 años, 5 meses
Puntos: 5
Respuesta: dudas con alias

Como tu dices el uso de la clausula AS es opcional pero como buena practica se recomienda el uso de la misma, mira lo que dice la documentacion de mysql:

Cita:
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. For example:

SELECT CONCAT(last_name,', ',first_name) AS full_name
FROM mytable ORDER BY full_name;

The AS keyword is optional when aliasing a select_expr. The preceding example could have been written like this:

SELECT CONCAT(last_name,', ',first_name) full_name
FROM mytable ORDER BY full_name;

However, because the AS is optional, a subtle problem can occur if you forget the comma between two select_expr expressions: MySQL interprets the second as an alias name. For example, in the following statement, columnb is treated as an alias name:

SELECT columna columnb FROM mytable;

For this reason, it is good practice to be in the habit of using AS explicitly when specifying column aliases.

It is not allowable to refer to a column alias in a WHERE clause, because the column value might not yet be determined when the WHERE clause is executed. See Section B.1.5.4, “Problems with Column Aliases”.
Atentamente,
Edson Gonzales.
__________________
"El Conocimiento es de todos, no solo de algunos"