You can apply an alias to tables, columns, or column expressions when you enter their names in a query. When making further references to the table or column in the same statement, you can use the alias instead of the original name. You usually choose aliases that are either shorter or easier to recall than the original names. Because the aliases are printed in the query header, they can be used to self-document output.
In the SELECT list or FROM list of a query, add the AS alias clause directly after any table, column, or expression name to create an alias. You can specify the alias straight after the original name without using the AS keyword.
— The below command helps to make the column headers of the result set easier to understand.
SELECT
StudentName AS Name,
AddressDetails AS Address,
ContactInfo AS Phone
FROM tbStudentDetails;
SELECT
SUM(Salary + Commission) AS TotalIncome
FROM tbEmployee;
— The AS keyword is optional.
SELECT StudentName “Name”, Contactinfo “Mobile” FROM tbStudentDetails;
Hope you find this article helpful.
Please subscribe for more interesting updates.
One comment