Contents /
Previous /
Next
Aliases: AS
Aliases can be used for column names and table names.
> SELECT column AS column_alias FROM table
> SELECT column FROM table AS table_alias
Example:
> SELECT name AS "first name", id FROM stud;
first name | id
------------+----
fred | 1
tom | 3
john | 4
lisa | 2
(4 rows)
With table aliases, you can join a table to itself in a self-join.
In this case, the same table is given two different alias names.