MySQL AS Keyword

I am not a professional in writing queries, but have written a lot from the moment MySQL started. I recently noticed that there is no need to enter a keyword ASin the alias of the name.

SELECT name AS n

equally

SELECT name n

However, I know that this ability was missing many years ago. I have 2 questions on this:

  • Is the ASkeyword redundant?
  • Sometimes, when I came across a user request on a website that was not ASin aliasing, running it turned off the MySQL service, I changed the way the aliases with the keywords were added AS, and this small change made it work!

    What was the problem?

+4
source share
1 answer

1), mysql http://dev.mysql.com/doc/refman/5.0/en/select.html:

A select_expr AS alias_name. GROUP BY, ORDER BY HAVING. :

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

AS select_expr . :

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

, AS , , select_expr: MySQL - . , , columnb :

SELECT columna columnb FROM mytable;

AS .

WHERE, , WHERE . . C.5.5.4 " ".

:

tbl_name AS alias_name tbl_name alias_name:

SELECT t1.name, t2.salary FROM employee AS t1, info AS t2   WHERE
t1.name = t2.name;

SELECT t1.name, t2.salary FROM employee t1, info t2   WHERE t1.name =
t2.name;

2) , , .

+11

All Articles