SQL Aliasing

SQL Aliases

SQL aliases are actually temporary names given to tables or a column or columns in a table. They do not actually create a new column in the database, but are the temporary readable names given to columns or tables for the time of the execution of the query. So, they only exists for the duration of the query.

Syntax to ALIAS A COLUMN

SELECT column_name AS alias_name
FROM table_name;

Syntax to ALIAS a TABLE

SELECT column_name(s)
FROM table_name AS alias_name;

Example to Alias a column

If you want to select students with percentage >=80 and want to view them as A graders, you can write the query as follows

Select Student_Name as A_Graders,Marks from English_Results where percentage>=80;

Example to Alias a table

Select * from Results as Class_8th_Results; 

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Blog at WordPress.com.

Up ↑

Design a site like this with WordPress.com
Get started