Alias (AS)

An alias is a temporary name you give a column or table in a query using the AS keyword. It makes results more readable and shortens table names in joins.

SQL

Column aliases rename the output, which is especially useful for aggregates — turning COUNT(*) into a friendly heading like 'total'. Table aliases let you write users u and then refer to u.name.

The AS keyword is optional in many databases; you can often just write the alias after the column or table name.

Syntax

SELECT column AS alias_name FROM table_name AS t;

Examples

SQL

SELECT name AS full_name, age AS years
FROM users;

Output:

full_name  years
---------  -----
Alice      30

Learn it in a lesson

See also

Back to the Dictionary