Help Center/
Data Lake Insight/
SQL Syntax Reference (ME-Abu Dhabi Region)/
Spark SQL Syntax Reference/
Alias/
AS for Table
Updated on 2023-03-06 GMT+08:00
AS for Table
Function
This statement is used to specify an alias for a table or the subquery result.
Syntax
1
|
SELECT attr_expr_list FROM table_reference [AS] alias; |
Keyword
- table_reference: Can be a table, view, or subquery.
- As: Is used to connect to table_reference and alias. Whether this keyword is added or not does not affect the command execution result.
Precautions
- The to-be-queried table must exist. Otherwise, an error is reported.
- The alias must be specified before execution of the statement. Otherwise, an error is reported. You are advised to specify a unique alias.
Example
- To specify alias n for table simple_table and visit the name field in table simple_table by using n.name, run the following statement:
1
SELECT n.score FROM simple_table n WHERE n.name = "leilei";
- To specify alias m for the subquery result and return all the query results using SELECT * FROM m, run the following statement:
1
SELECT * FROM (SELECT * FROM simple_table WHERE score > 90) AS m;
Parent topic: Alias
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot