In the previous articles, Taimienphi.vn introduced you to SQL commands, including DELETE, CREATE, RENAME, … and SQL clauses including WHERE, LIKE, IN statements. , …. This article Taimienphi.vn will introduce you more about Alias in SQL.
Alias, also known as aliases in SQL, is used to define columns and tables. Basically Aliases in SQL are created to make the selected columns more readable.
Examples of Alias in SQL
To select the names of all students in the class, the Alias query in SQL looks like this:
Alias for columns in SQL:
SELECT first_name AS Name FROM student_details;
SELECT first_name Name FROM student_details;
In the above query, the column first_name aliases are provided Name. So when the result is displayed, the column name will display as Name, not first_name.
Alias (alias) for the table:
SELECT s.first_name FROM student_details s;
In the above query, the alias “S“is used to define tables student_details and columns first_name selected from the table.
Some notes with Alias in SQL
Alias in SQL is more useful when:
– There are multiple tables related to a query.
– Functions used in the query
– Column names are large or unreadable.
– Multiple columns are combined together.
The above is information about Alias in SQL. To learn more about SQL statements, readers can refer to the series of SQL commands or How to deploy SQL Server through PowerShell DSC on Taimienphi.vn page.