SQL Tutorial - Learn SQL

SQL Aliases - SQL Tutorial

SQL aliases can be used with database tables and with database table columns, depending on task you are performing.

SQL column aliases are used to make the output of your SQL queries easy to read and more meaningful:

SELECT Employee, SUM(Hours) As SumHoursPerEmployee
FROM EmployeeHours
GROUP BY Employee

In the example above we created SQL alias SumHoursPerEmployee and the result of this SQL query will be the following:

Employee SumHoursPerEmployee
John Smith 25
Allan Babel 24
Tina Crown 27

Consider the following SQL statement, showing how to use SQL table aliases:

SELECT Emp.Employee
FROM EmployeeHours AS Emp

Here is the result of the SQL expression above:

John Smith
Allan Babel
Tina Crown

The SQL table aliases are very useful when you select data from multiple tables.