Salve a tutti non riesco a trovare una spiegazione dettagliata o comunque chiara e definita della parola riservata AS in MYSQL. C'e qualcuno che sa darmi una dritta?
Grazie a tutti,
Salve a tutti non riesco a trovare una spiegazione dettagliata o comunque chiara e definita della parola riservata AS in MYSQL. C'e qualcuno che sa darmi una dritta?
Grazie a tutti,
http://dev.mysql.com/doc/refman/5.0/en/select.html
http://dev.mysql.com/doc/refman/5.0/...ith-alias.html
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”.