This site runs best with JavaScript enabled.Lesson 31: Using a Column Alias.

Lesson 31: Using a Column Alias.


What is a Column Alias and why would we use it?

Just as we used an alias for a table name in our previous lesson, we can also use an alias for a column name.

The syntax is the same ("AS alias_name") and helps us clear up any confusion when fields from different tables have the same name (but hold different data).

The Column Alias is also useful for tidying up our SQL code and results if the column names are long, repetitive or not particularly easy to decipher.

SELECT ID,
Actor_First_Name as FName,
Actor_Last_Name as Surname,
Actor_Date_Of_Birth as DOB,
Actor_Annual_Earnings as Income
FROM Movies;

In this example, we've taken some very longwinded Column names (such as Actor_First_Name) and made them into a more readable Column Alias (e.g. FName).

Quiz Time.

The Question.

Let's link our movies and actors back together but this time we only want to see two columns returned - 1) movie_name (which is the title of the movie) and 2) actor_name (which is the actor's name).

The Data.

The Editor.



The Answer.

Correct SQL:

Correct Output:

Share lesson