WHAT ARE SQL ALIASES

ALIASES in SQL

The aliases in SQL are used to give temporary name to a table or a column in a table. An alias is created with the AS keyword.

Syntax of alias in SQL for the column-

SELECT <column_name1> AS <alias_name1>, ….

    <column_nameN> AS <alias_nameN>

FROM <table_name>;

Syntax of alias in SQL for table-

SELECT<column_name(s)> FROM <table_name> AS <alias_name>;

Example of alias in SQL for column-

SELECT CustomerName AS Customer, PostalCode AS [Postal Code]

FROM Customers;

Example of alias in SQL for table-

SELECT ord.OrderID , cus.CustomerName FROM Customers AS cus, Orders AS ord

WHERE cus.CustomerID=ord.OrderID;


Leave a Reply

Your email address will not be published. Required fields are marked *