One of the most common types of expressions is the column name. The general format is fairly simple, consisting of just the column name. If there is any ambiguity between different tables, you can prefix the column name with an optional table name or a database and table name.
Identifiers (database names, table names, or
column names) that include nonstandard characters can be enclosed in double
quotes ( ""
) or square brackets (
[]
) to escape them. For example
[
.table
name
].[column
name
]
Column name expressions are always evaluated
in some type of context. For example, if you’re formulating a WHERE
expression that is part of a SELECT
statement, the expression defined
there will be evaluated once for each possible row in the result set. As
each row is processed, the value of the column for that row will be put into
the expression and the expression will be evaluated. The context defines
what column references are available to any particular expression.
In addition to actual table columns, many
expressions within a SELECT
statement can
also reference columns from the result set by referencing the alias assigned
in an AS
clause. Similarly, if a source
table in the FROM
clause is assigned a
table alias, this alias must be used in any table reference. The use of
table aliases is especially common when formulating join condition
expressions on self-joins (a table joined to itself), and other situations
when you need to refer to a specific instance of a specific table. A table
alias can also be assigned to a nameless subquery.
3.14.15.94