| PostgreSQL Reference Manual - Volume 1 - SQL Language Reference by The PostgreSQL Global Development Group Paperback (6"x9"), 716 pages ISBN 0954612027 RRP £32.00 ($49.95) Sales of this book support the PostgreSQL project! Get a printed copy>>> |
5.3.1 Select-List Items
The simplest kind of select list is * which
emits all columns that the table expression produces. Otherwise,
a select list is a comma-separated list of value expressions (as
defined in section 2.2 Value Expressions). For instance, it
could be a list of column names:
SELECT a, b, c FROM ...
The columns names a, b, and c
are either the actual names of the columns of tables referenced
in the FROM clause, or the aliases given to them as
explained in section 5.2.1.2 Table and Column Aliases. The name
space available in the select list is the same as in the
WHERE clause, unless grouping is used, in which case
it is the same as in the HAVING clause.
If more than one table has a column of the same name, the table name must also be given, as in
SELECT tbl1.a, tbl2.a, tbl1.b FROM ...
When working with multiple tables, it can also be useful to ask for all the columns of a particular table:
SELECT tbl1.*, tbl2.a FROM ...
(See also section 5.2.2 The WHERE Clause.)
If an arbitrary value expression is used in the select list, it
conceptually adds a new virtual column to the returned table. The
value expression is evaluated once for each result row, with
the row's values substituted for any column references. But the
expressions in the select list do not have to reference any
columns in the table expression of the FROM clause;
they could be constant arithmetic expressions as well, for
instance.
| ISBN 0954612027 | PostgreSQL Reference Manual - Volume 1 - SQL Language Reference | See the print edition |