We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

AS Clause in SQL

Sometimes we need to structure the data we return from our queries in a specific way. An AS clause allows us to "alias" a piece of data in our query. The alias exists only for the duration of the query.

AS Keyword

The following queries return the same data:

SELECT employee_id AS id, employee_name AS name
FROM employees;
SELECT employee_id, employee_name
FROM employees;

The difference is that the results from the aliased query would have column names id and name instead of employee_id and employee_name.

Throughout the course, use aliases only when requested.

Assignment

A user has asked us to find all the transactions on their account from their grandmother. We thought it would be fun to rename the note field to birthday_message because we noticed all the transactions from Grandma are birthday messages.