AS keyword. They make output more readable, simplify complex queries, and are essential when working with JOINs. In this chapter, you will learn column aliases, table aliases, and when to use each.Column Aliases
A column alias renames a column in the query output. The actual table is not changed:
SELECT Name AS EmployeeName,
Salary AS MonthlySalary
FROM Employees;
+--------------+---------------+ | EmployeeName | MonthlySalary | +--------------+---------------+ | Priya K. | 55000 | | John D. | 62000 | | Arun M. | 78000 | | Emma W. | 51000 | | Ravi S. | 72000 | | Sara L. | 58000 | +--------------+---------------+
Aliases with Calculations
Aliases are especially useful for calculated columns that have no natural name. You learned about aggregate functions like SUM and AVG earlier — aliases make their output readable:
SELECT Name,
Salary * 12 AS AnnualSalary,
Salary * 12 * 0.10 AS AnnualTax
FROM Employees;
+-----------+--------------+-----------+ | Name | AnnualSalary | AnnualTax | +-----------+--------------+-----------+ | Priya K. | 660000 | 66000 | | John D. | 744000 | 74400 | | Arun M. | 936000 | 93600 | +-----------+--------------+-----------+
Aliases with Spaces
If your alias contains spaces, wrap it in quotes or brackets:
SELECT Name AS 'Employee Name',
City AS 'Work Location'
FROM Employees;
AS Is Optional
The AS keyword is optional in most databases. These two are identical:
SELECT Name AS EmployeeName FROM Employees;
SELECT Name EmployeeName FROM Employees;
💡 Best Practice
Always include AS even though it is optional. It makes your queries clearer and easier to read, especially in complex queries with multiple aliases.
Table Aliases
Table aliases give a short name to a table. This is especially useful with JOINs:
SELECT e.Name, e.Department, e.Salary
FROM Employees AS e
WHERE e.Salary > 60000;
+-----------+------------+--------+ | Name | Department | Salary | +-----------+------------+--------+ | John D. | Marketing | 62000 | | Arun M. | IT | 78000 | | Ravi S. | IT | 72000 | +-----------+------------+--------+
The table Employees is aliased as e. You can then use e.Name instead of Employees.Name.
Table Aliases with JOINs
Table aliases become essential when joining multiple tables:
SELECT e.Name, d.DepartmentName, e.Salary
FROM Employees AS e
INNER JOIN Departments AS d
ON e.DeptID = d.ID;
Without aliases, you would need to write Employees.Name and Departments.DepartmentName every time. Aliases save typing and improve readability. You will learn JOINs in detail in the next chapter.
When to Use Aliases
| Situation | Alias Type | Example |
|---|---|---|
| Rename output columns | Column alias | Salary AS Pay |
| Label calculated columns | Column alias | Salary * 12 AS Annual |
| Shorten table names in JOINs | Table alias | Employees AS e |
| Self-joins (same table twice) | Table alias | Employees AS e1, Employees AS e2 |
| Aggregate function output | Column alias | COUNT(*) AS Total |
For a complete reference of the SELECT syntax, see the official MySQL SELECT documentation.
If you work with data regularly, explore our ready-made Dashboard Templates on NextGenTemplates that use SQL-powered data for business reporting.
📺 Visit our YouTube channel @NeoTechNavigators for step-by-step video tutorials and dashboard demos on this topic.
🧪 Try It Yourself
Write a query that shows each employee’s Name (as “Employee”), Department (as “Team”), and Salary increased by 15% (as “NewSalary”).
SELECT Name AS Employee,
Department AS Team,
Salary * 1.15 AS NewSalary
FROM Employees;
📝 What You Learned in This Chapter
AScreates temporary names for columns and tables- Column aliases rename output columns without changing the table
- Table aliases shorten table names for readability, especially in JOINs
- AS is optional but recommended for clarity
- Use quotes for aliases with spaces
- Aliases only exist for the duration of the query
Frequently Asked Questions
AS keyword. It exists only for the duration of the query and does not change the actual database. Aliases make output readable and simplify complex queries.SELECT Name AS Employee and SELECT Name Employee both work. However, using AS is strongly recommended for clarity and readability.📖 Chapter 19 of 30 — SQL Tutorial on Neotech Navigators


