MYSQL Tutorial



MySQL ALIASES


MySQL Aliases

Aliases let you rename a table or a column temporarily in your query result. This is helpful to make column names more readable or to shorten table names in complex queries.

Column Aliases

Use the AS keyword or just a space to create an alias for a column.

SELECT first_name AS 'Name', salary AS 'Monthly Salary'
FROM employees;
  

The columns first_name and salary will appear as Name and Monthly Salary in the results.

Table Aliases

Aliases are especially useful when you use joins or subqueries. You can rename tables to shorter names for easier referencing.

SELECT e.first_name, d.department_name
FROM employees AS e
JOIN departments AS d ON e.department_id = d.department_id;
  

Here, employees is aliased as e and departments as d for simpler referencing.

Quick Tips

  • Use quotes (single or double) if alias has spaces or special characters.
  • Aliases only affect output column or table names, not actual database schema.
  • You can skip the AS keyword and just write column_name alias_name.

🌟 Enjoyed Learning with Us?

Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!

Leave a Google Review