SQL ALIAS

An alias is another name to a table or column, and is used to simplify SQL statements when the name of tables or columns are long or complicated.

ALIAS SQL syntax for a table

SELECT column FROM tableName AS tableAlias

SQL syntax for a column ALIAS

SELECT columnName AS columnAlias FROM table

Examples SQL ALIAS

Given the following table 'people'

namesurnamenickname
HARRYCLARKWHITE
HARRYSMITHJOHNSON
JOHNBROWNANDERSON

We used the alias 'p' for table 'people', to simplify the SELECT statement

SELECT p.surname, p.nickname FROM people AS p WHERE p.name = 'HARRY'

surnamenickname
HARRYCLARK
HARRYSMITH

Without using the alias, the SELECT statement would be a little longer:

SELECT people.surname, people.des FROM people WHERE people.name = 'HARRY'

surnamenickname
HARRYCLARK
HARRYSMITH