bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/SQL/SQL Tutorial
SQL•SQL Tutorial

SQL Aliases

Concept visual

SQL Aliases

Pointer walk
two pointers
leftright102132436485116
left=0
right=6
1
3

Start at both ends

Overview

SQL aliases are used to give a column or a table a temporary name. Aliases are used to make column names more readable. An alias only exists for the duration of that query.

An alias is created with the AS

keyword.

Alias for Columns

The following SQL creates two aliases, one for the CustomerID column and one for the CustomerName column:

Example

SELECT CustomerID AS ID, CustomerName AS Customer

FROM Customers;

Syntax

Alias for column:

Select

column_name AS alias_name

From

table_name;

Alias for table:

Select

column_name(s)

From

table_name AS

alias_name;

Demo Database

Below is a selection from the

Customers and

Orders tables used in the examples:

Customers

CustomerID

CustomerName

ContactName

Address

City

PostalCode

Country

Alfreds Futterkiste

Maria Anders

Obere Str. 57

Previous

SQL BETWEEN Operator

Next

SQL Joins