I found a SQL statement to the effect of:
SELECT * FROM Users x
My question is: what is x? I have never seen this before.
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s an alias. The
ASkeyword is optional and has been left out, but it is the same as:This means you can (in some implementations of SQL, SQL Server being one of them, must) use
xin the rest of the query to refer back to the tableUsersspecified here. For example:There are three general use cases for aliases:
Readability. For long table names or when the name will be used many times, it can improve readability. For example, imagine the following without the alias:
Disambiguation. Often used for self-joins, note the use of the same table twice. You must use an alias to differentiate the two instances of the
Userstable:Sub-queries in a FROM or JOIN clause (also called derived tables) must have a name. This is done by specifying an alias: