---
title: "What is an ALIAS command in SQL Server, where apply alias in the database command?"  
description: "What is an ALIAS command in SQL Server, where apply alias in the database command?"  
author: "Ravi Vishwakarma"  
published: 2021-09-22  
updated: 2021-09-22  
canonical: https://www.mindstick.com/forum/156744/what-is-an-alias-command-in-sql-server-where-apply-alias-in-the-database-command  
category: "database"  
tags: ["database", "mysql", "sql server", "sql"]  
reading_time: 3 minutes  

---

# What is an ALIAS command in SQL Server, where apply alias in the database command?

What is an ALIAS [command in SQL](https://www.mindstick.com/forum/34655/what-is-the-difference-in-drop-delete-and-truncate-command-in-sql-server) [Server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over), where [apply](https://www.mindstick.com/articles/13148/discover-to-apply-make-up-like-a-professional-supermodel) alias in the [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax) command?

## Replies

### Reply by Ashutosh Kumar Verma

## [SQL](https://www.mindstick.com/articles/13115/types-of-keys-in-sql-or-oracle-database) 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-

```
SELECT column_name AS alias_name FROM table_name;
```

We can also create alias for multiple column in a table.

```
SELECT column1 AS alias1, column2 AS alias2 ,… FROM table_name ;
```

## Alias for Table-

```
SELECT colum1,column2,… FROM table_name AS alias_name ;
```

## Example :

Lets have a table ‘Customer’,

![What is an ALIAS command in SQL Server, where apply alias in the database command?](https://www.mindstick.com/mindstickforums/5716e30d-2b32-4dc6-a288-db06c16f0427/images/e6543095-fe75-40fc-b52f-21b4bb8996c7.png)

Follow the statement is used alias for table column ‘cust_name’ as ‘name’ and ‘city’ as ‘c’ .

```
select cust_name as name, city as c from Customer;
```

![What is an ALIAS command in SQL Server, where apply alias in the database command?](https://www.mindstick.com/mindstickforums/5716e30d-2b32-4dc6-a288-db06c16f0427/images/5367a608-458b-43d0-a441-e13467385a46.png)

The following SQL statement is using alias for a table ‘Customer’ as ‘cust’.

```
select cust.cust_name,cust.city,cust.customer_id from Customer as cust;
```

![What is an ALIAS command in SQL Server, where apply alias in the database command?](https://www.mindstick.com/mindstickforums/5716e30d-2b32-4dc6-a288-db06c16f0427/images/95da2a79-503b-4cbf-8eb4-b9759b034632.png)\

We can also provide aliases to retrieve record from more than one table at a time like below.

```
select cust.cust_name,cust.city,cust.customer_id, sale.salesman_id, sale.name
from Customer as cust,Salesman as sale where cust.salesman_id=sale.salesman_id;
```

![What is an ALIAS command in SQL Server, where apply alias in the database command?](https://www.mindstick.com/mindstickforums/5716e30d-2b32-4dc6-a288-db06c16f0427/images/f9c2c587-6376-48ec-bfc6-309170c7dc75.png)

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.

```
 select customer_id, cust_name+','+city as name from Customer;
```

![What is an ALIAS command in SQL Server, where apply alias in the database command?](https://www.mindstick.com/mindstickforums/5716e30d-2b32-4dc6-a288-db06c16f0427/images/767fc8fe-8714-4d6c-a063-422ce89b834d.png)

To give space between alias name use [alias name] in SQL statement.

```
select customer_id, cust_name+' , '+city as [name  address] from Customer;
```

![What is an ALIAS command in SQL Server, where apply alias in the database command?](https://www.mindstick.com/mindstickforums/5716e30d-2b32-4dc6-a288-db06c16f0427/images/bc22708e-b79e-40e3-b45f-8fe1073b1f59.png)

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.

```
select cust.customer_id, cust.cust_name,sale.salesman_id,sale.name
from Customer as cust, Salesman as sale
where cust.cust_name='Brad Davis' AND cust.salesman_id=sale.salesman_id;
```

![What is an ALIAS command in SQL Server, where apply alias in the database command?](https://www.mindstick.com/mindstickforums/5716e30d-2b32-4dc6-a288-db06c16f0427/images/049c033d-3da4-43ea-afda-ca128ccee920.png)\


---

Original Source: https://www.mindstick.com/forum/156744/what-is-an-alias-command-in-sql-server-where-apply-alias-in-the-database-command

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
