Column Aliases

The column that you select in a query can be given a different name i.e. column alias name for output purposes. For instance consider a table named school and it has a column class, so the name of the column class can be changed to any other name like Standard and can be displayed as a result.

Syntax

select columnname as "alias name" 
from tablename; 

Example

Table before using alias.
select Roll, Name, Class, Section, Subject, Score As "Marks"
from students;
Table after alias.

Aliases are used to give more readable column names. These aliases are not permanent, they last only for the particular query, the permanent name of the column still remains the same. It can also be used to give an alternate name to the table as well, using the similar syntax with some changes.

Syntax for table alias

select column name 
from tablename as alias name;

Leave a comment

Create a website or blog at WordPress.com

Up ↑

Design a site like this with WordPress.com
Get started