What is an ALIAS command?

ALIAS name can be given to a table or column. This alias name can be referred in WHERE clause to identify the table or column.

Example

Employee Table

emp_id emp_name salary dept_id manager_id
E1 Rahul 15000 D1 M1
E2 Manoj 15000 D1 M1
E3 James 55000 D2 M2
E4 Michael 25000 D2 M2
E5 Ali 20000 D10 M3
E6 Robin 35000 D10 M3

Department Table

dept_id dept_name
D1 IT
D2 HR
D3 Finance
D4 Admin

Alias For Table

SELECT e.dept_id, d.dept_id,d.dept_name,e.emp_name
FROM Employee as e, Department as d
WHERE e.dept_id=d.dept_id;

Here, e refers to alias name for Employee table and d refers to alias name for Department table.

Alias For Column

SELECT emp_name as 'Employee Name' FROM Employee;

Output

Employee Name
Rahul
Manoj
James
Michael
Ali
Robin

Here, Employee Name refers to alias name for emp_name column.