A table alias is a temporary name given to a table within a query. It is especially useful when working with joins or referencing the same table multiple times.
Short table aliases make complex queries easier to read and reduce repetitive table names.
The Employees table can be given the alias e and referenced as e.EmployeeName.
SELECT
e.EmployeeName,
e.Salary
FROM Employees AS e;
Table aliases are commonly used in JOIN queries, self joins, subqueries, and complex reporting queries.
- Table aliases are temporary.
- They shorten table references.
- They are useful in joins.
- They improve query readability.
- They are useful when the same table appears multiple times.
Why use table aliases?
Table aliases make queries shorter and easier to read, especially when multiple tables are involved.
Are table aliases permanent?
No. A table alias exists only for the duration of the query.