How to Use Column Alias in MySQL

Notes:

How to use Column Alias in MySQL:
- Column alias indicates an alternative descriptive name for the column.
- To give an alternative descriptive name for the column; we take help of as keyword or just a space.

Note: While displaying data from the table if you are not happy with original columns name and if you want to give an alternative descriptive name for the columns then you take help of column alias.

Basic Syntax:
original_colum_name [as] alias_name_for_the_column

Ex:
select id as roll_number, name as student_name from tbl_student;

Note: If an alias name contains a space(s), then it must be enclosed in between pair of single quotations.

Ex:
select id as ‘roll number’ , name as ‘student name’ from tbl_student;

Note: using as keyword is optional

Ex:
select id roll_number , name student_name from tbl_student;
select id ‘roll number’ , name ‘student name’ from tbl_student;

Interview Questions: