7.3.1. Select-List Items
7.3.1.选择列表项
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 4.2). For
instance, it could be a list of column names:
选择列表最简单的一种类型就是*,它选择表中的所有列。否则,选择列表是一个以逗号分隔的列表(正如
4.2节所定义的)。例如,可以使列名的列表:
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 7.2.1.2. 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.
列名a,b,c可以是FROM后所选择表的实际列名,也可以是在
7.2.1.2节所提及的别名。
选择列表中可用的名称空间与WHERE子句中的名称空间相同,除非使用了分组,在这种情况下,它与HAVING子句中的名称空间相同。
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 Section 8.16.5 for more about the
table_name
.*
notation.
关于table_name.*的更多信息,请参见
8.16.5节。
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 can be constant arithmetic expressions,
for instance.
如果在选择列表中使用了任意值表达式,则从概念上讲它将新的虚拟列添加到返回的表中。对于每个结果行,将对值表达式进行一次评估,并用该行的值替换任何列引用。 但是选择列表中的表达式不必引用FROM子句的表表达式中的任何列。 例如,它们可以是常量算术表达式。