☰ See All Chapters |
MySQL Column Aliases
SQL aliases are used to temporarily rename a table or a column heading.
SQL aliases are used to give a database table or a column in a table, a temporary name.
Basically aliases are created to make column names more readable.
Alias is used generally when
The column names are big and not readable.
Functions are use in a SELECT query.
When there are more than two tables used in a SELECT query.
SQL Alias Syntax for Columns
SELECT column_name AS alias_name FROM table_name; |
SQL Alias Syntax for Tables
SELECT column_name(s) FROM table_name AS alias_name; |
Example of Aliases in SQL Query for column names

If you execute the query below:
select FIRST_NAME as FN, LAST_NAME as LN from EMPLOYEE; |
The result set will look like this:

Example of Alias in SQL Query for Tables
Consider the following two tables:


Below is the query to fetch data from both tables using SQL alias:
select e.EMPLOYEE_ID, e.FIRST_NAME, e.LAST_NAME, ec.COUNTRY from EMPLOYEE e, EMPLOYEE_COUNTRY ec where e.EMPLOYEE_ID = ec.EMPLOYEE_ID; |
Result table look like:

All Chapters