What is an ALIAS command in SQL Server, where apply alias in the database command?
What is an ALIAS command in SQL Server, where apply alias in the database command?
31522-Sep-2021
Updated on 22-Sep-2021
Home / DeveloperSection / Forums / What is an ALIAS command in SQL Server, where apply alias in the database command?
Ashutosh Kumar Verma
24-Sep-2021SQL Aliases :
SQL aliases are used to give a temporary name to tables or columns in table. It is exist only duration of that query in perform. Alias are used to provide a easier name to table or column of table. An alias is create with use of ‘AS’ keyword.
Syntax :
Alias for column-
We can also create alias for multiple column in a table.
Alias for Table-
Example :
Lets have a table ‘Customer’,
Follow the statement is used alias for table column ‘cust_name’ as ‘name’ and ‘city’ as ‘c’ .
The following SQL statement is using alias for a table ‘Customer’ as ‘cust’.
We can also provide aliases to retrieve record from more than one table at a time like below.
We can also provide single alias for two or more columns in a table at a time. In the following statement a alias ‘name’ for column name ‘cust_name’ and ‘city’ in ‘Customer’ table.
To give space between alias name use [alias name] in SQL statement.
In the following statement select a record where customer_id=3007(Brad Davis). By using ‘Customer’ and ‘Salesman’ table and give the alias name as ‘cust’ and ‘sale’ respectively.