Commit 4dce924b authored by Thomas G. Lockhart's avatar Thomas G. Lockhart

Minor wording and formatting cleanups.

parent b6bdc435
<REFENTRY ID="SQL-SELECT-1"> <refentry id="SQL-SELECT">
<REFMETA> <refmeta>
<REFENTRYTITLE> <refentrytitle>
SELECT SELECT
</REFENTRYTITLE> </refentrytitle>
<REFMISCINFO>SQL - Language Statements</REFMISCINFO> <refmiscinfo>SQL - Language Statements</refmiscinfo>
</REFMETA> </refmeta>
<REFNAMEDIV> <refnamediv>
<REFNAME> <refname>
SELECT SELECT
</REFNAME> </refname>
<REFPURPOSE> <refpurpose>
Retrieve rows from a table or view Retrieve rows from a table or view.
</REFPURPOSE> </refpurpose></refnamediv>
<REFSYNOPSISDIV> <refsynopsisdiv>
<REFSYNOPSISDIVINFO> <refsynopsisdivinfo>
<DATE>1998-04-15</DATE> <date>1998-09-06</date>
</REFSYNOPSISDIVINFO> </refsynopsisdivinfo>
<SYNOPSIS> <synopsis>
<REPLACEABLE CLASS="PARAMETER">
</REPLACEABLE>
SELECT [ALL|DISTINCT] SELECT [ALL|DISTINCT]
<REPLACEABLE CLASS="PARAMETER">expression</REPLACEABLE> [AS <REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE>] [, ...] <replaceable class="PARAMETER">expression</replaceable> [AS <replaceable class="PARAMETER">name</replaceable>] [, ...]
[INTO [TABLE] <REPLACEABLE CLASS="PARAMETER">intable</REPLACEABLE>] [INTO [TABLE] <replaceable class="PARAMETER">intable</replaceable>]
[FROM <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> [<REPLACEABLE CLASS="PARAMETER">alias</REPLACEABLE>] [, ...] ] [FROM <replaceable class="PARAMETER">table</replaceable> [<replaceable class="PARAMETER">alias</replaceable>] [, ...] ]
[WHERE <REPLACEABLE CLASS="PARAMETER">condition</REPLACEABLE>] [WHERE <replaceable class="PARAMETER">condition</replaceable>]
[GROUP BY <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> [, ...] ] [GROUP BY <replaceable class="PARAMETER">column</replaceable> [, ...] ]
[HAVING <REPLACEABLE CLASS="PARAMETER">condition</REPLACEABLE> [, ...] ] [HAVING <replaceable class="PARAMETER">condition</replaceable> [, ...] ]
[UNION [ALL] <REPLACEABLE CLASS="PARAMETER">select</REPLACEABLE>] [UNION [ALL] <replaceable class="PARAMETER">select</replaceable>]
[ORDER BY <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> [ASC | DESC] [, ...] ] [ORDER BY <replaceable class="PARAMETER">column</replaceable> [ASC | DESC] [, ...] ]
</SYNOPSIS> </synopsis>
<REFSECT2 ID="R2-SQL-SELECT-1"> <refsect2 id="R2-SQL-SELECT-1">
<REFSECT2INFO> <refsect2info>
<DATE>1998-04-15</DATE> <date>1998-09-06</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Inputs Inputs
</TITLE> </title>
<PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<REPLACEABLE CLASS="PARAMETER">expression</REPLACEABLE> <replaceable class="PARAMETER">expression</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The name of a table's column or an expression. The name of a table's column or an expression.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE> <replaceable class="PARAMETER">name</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Specifies another name for a column or an expression using Specifies another name for a column or an expression using
the AS clause. <REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE> cannot be used in the WHERE the AS clause. <replaceable class="PARAMETER">name</replaceable>
cannot be used in the WHERE
condition. It can, however, be referenced in associated condition. It can, however, be referenced in associated
ORDER BY or GROUP BY clauses. ORDER BY or GROUP BY clauses.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<REPLACEABLE CLASS="PARAMETER">intable</REPLACEABLE> <replaceable class="PARAMETER">intable</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
If the INTO TABLE clause is specified, the result of the If the INTO TABLE clause is specified, the result of the
query will be stored in another table with the indicated query will be stored in another table with the indicated
name. name.
If <REPLACEABLE CLASS="PARAMETER">intable</REPLACEABLE> does not exist, it will be created automatically. If <replaceable class="PARAMETER">intable</replaceable> does
not exist, it will be created automatically.
<Note>
<Para> <note>
The CREATE TABLE AS statement will also create a new table from a select query. <para>
</Para> The <command>CREATE TABLE AS</command> statement will also
</Note> create a new table from a select query.
</PARA> </para>
</LISTITEM> </note>
</VARLISTENTRY> </para>
</listitem>
<VARLISTENTRY> </varlistentry>
<TERM>
<REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> <varlistentry>
</TERM> <term>
<LISTITEM> <replaceable class="PARAMETER">table</replaceable>
<PARA> </term>
The name of an existing table referenced by FROM clause. <listitem>
</PARA> <para>
</LISTITEM> The name of an existing table referenced by the FROM clause.
</VARLISTENTRY> </para>
</listitem>
<VARLISTENTRY> </varlistentry>
<TERM>
<REPLACEABLE CLASS="PARAMETER">alias</REPLACEABLE> <varlistentry>
</TERM> <term>
<LISTITEM> <replaceable class="PARAMETER">alias</replaceable>
<PARA> </term>
An alternate name for the preceeding <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>. <listitem>
Used for brevity or to eliminate ambiguity for joins within a single table. <para>
</PARA> An alternate name for the preceding
</LISTITEM> <replaceable class="PARAMETER">table</replaceable>.
</VARLISTENTRY> It is used for brevity or to eliminate ambiguity for joins
within a single table.
<VARLISTENTRY> </para>
<TERM> </listitem>
<REPLACEABLE CLASS="PARAMETER">condition</REPLACEABLE> </varlistentry>
</TERM>
<LISTITEM> <varlistentry>
<PARA> <term>
An expression leading to a boolean (true/false) result. <replaceable class="PARAMETER">condition</replaceable>
See the WHERE clause. </term>
</PARA> <listitem>
</LISTITEM> <para>
</VARLISTENTRY> A boolean expression giving a result of true or false.
See the WHERE clause.
<VARLISTENTRY> </para>
<TERM> </listitem>
<REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> </varlistentry>
</TERM>
<LISTITEM> <varlistentry>
<PARA> <term>
<replaceable class="PARAMETER">column</replaceable>
</term>
<listitem>
<para>
The name of a table's column. The name of a table's column.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<REPLACEABLE CLASS="PARAMETER">select</REPLACEABLE> <replaceable class="PARAMETER">select</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
A select statement with all features except the ORDER BY clause. A select statement with all features except the ORDER BY clause.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
</VARIABLELIST> </variablelist>
</PARA> </para>
</REFSECT2> </refsect2>
<REFSECT2 ID="R2-SQL-SELECT-2"> <refsect2 id="R2-SQL-SELECT-2">
<REFSECT2INFO> <refsect2info>
<DATE>1998-04-15</DATE> <date>1998-09-06</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Outputs Outputs
</TITLE> </title>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
Rows Rows
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The complete set of rows resulting from the query specification. The complete set of rows resulting from the query specification.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<ReturnValue>count</ReturnValue> <returnvalue>count</returnvalue>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The count of rows returned by the query. The count of rows returned by the query.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
</VARIABLELIST> </variablelist>
</REFSECT2> </refsect2>
</REFSYNOPSISDIV> </refsynopsisdiv>
<REFSECT1 ID="R1-SQL-SELECT-1"> <refsect1 id="R1-SQL-SELECT-1">
<REFSECT1INFO> <refsect1info>
<DATE>1998-04-15</DATE> <date>1998-09-06</date>
</REFSECT1INFO> </refsect1info>
<TITLE> <title>
Description Description
</TITLE> </title>
<PARA> <para>
SELECT is the principal means to access information
in <productname>Postgres</productname>.
SELECT will get all rows which satisfy the WHERE condition SELECT will get all rows which satisfy the WHERE condition
or all rows of a table if WHERE is omitted. or all rows of a table if WHERE is omitted.</para>
<PARA> <para>
The GROUP BY clause allows a user to divide a table The GROUP BY clause allows a user to divide a table
conceptually into groups. (See GROUP BY clause). conceptually into groups. (See GROUP BY clause).</para>
<para>
The HAVING clause specifies a grouped table derived by the The HAVING clause specifies a grouped table derived by the
elimination of groups from the result of the previously elimination of groups from the result of the previously
specified clause. (See HAVING clause). specified clause. (See HAVING clause).</para>
<para>
The ORDER BY clause allows a user to specify that he/she The ORDER BY clause allows a user to specify that he/she
wishes the rows sorted according to the ASCending or wishes the rows sorted according to the ASCending or
DESCending mode operator. (See ORDER BY clause) DESCending mode operator. (See ORDER BY clause)</para>
<para>
The UNION clause specifies a table derived from a Cartesian The UNION clause specifies a table derived from a Cartesian
product union join. (See UNION clause). product union join. (See UNION clause).</para>
<PARA> <para>
You must have SELECT privilege to a table to read its values You must have SELECT privilege to a table to read its values
(See GRANT/REVOKE statements). (See GRANT/REVOKE statements).</para>
<REFSECT2 ID="R2-SQL-WHERE-2"> <refsect2 id="R2-SQL-WHERE-2">
<REFSECT2INFO> <refsect2info>
<DATE>1998-04-15</DATE> <date>1998-09-06</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
WHERE clause WHERE clause
</TITLE> </title>
<PARA> <para>
The optional WHERE condition has the general form: The optional WHERE condition has the general form:
<Synopsis> <synopsis>
WHERE <REPLACEABLE CLASS="PARAMETER">expr</REPLACEABLE> <REPLACEABLE CLASS="PARAMETER">cond_op</REPLACEABLE> <REPLACEABLE CLASS="PARAMETER">expr</REPLACEABLE> [<REPLACEABLE CLASS="PARAMETER">log_op</REPLACEABLE> ...] WHERE <replaceable class="PARAMETER">expr</replaceable> <replaceable class="PARAMETER">cond_op</replaceable> <replaceable class="PARAMETER">expr</replaceable> [<replaceable class="PARAMETER">log_op</replaceable> ...]
</Synopsis> </synopsis>
where <REPLACEABLE CLASS="PARAMETER">cond_op</REPLACEABLE> can be one of: =, &lt;, &lt;=, &gt;, &gt;=, &lt;&gt; where <replaceable class="PARAMETER">cond_op</replaceable> can be
one of: =, &lt;, &lt;=, &gt;, &gt;=, &lt;&gt;
or a conditional operator like ALL, ANY, IN, LIKE, et cetera or a conditional operator like ALL, ANY, IN, LIKE, et cetera
and <REPLACEABLE CLASS="PARAMETER">log_op</REPLACEABLE> can be one of: AND, OR, NOT. and <replaceable class="PARAMETER">log_op</replaceable> can be one
of: AND, OR, NOT.
The comparison returns either TRUE or FALSE and all The comparison returns either TRUE or FALSE and all
instances will be discarded instances will be discarded
if the expression evaluates to FALSE. if the expression evaluates to FALSE.
</PARA> </para>
</REFSECT2> </refsect2>
<REFSECT2 ID="R2-SQL-GROUPBY-2"> <refsect2 id="R2-SQL-GROUPBY-2">
<REFSECT2INFO> <refsect2info>
<DATE>1998-04-15</DATE> <date>1998-09-06</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
GROUP BY clause GROUP BY clause
</TITLE> </title>
<PARA> <para>
GROUP BY specifies a grouped table derived by the application GROUP BY specifies a grouped table derived by the application
of the this clause: of the this clause:
<SYNOPSIS> <synopsis>
GROUP BY <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> [, ...] GROUP BY <replaceable class="PARAMETER">column</replaceable> [, ...]
</SYNOPSIS> </synopsis></para></refsect2>
<REFSECT2 ID="R2-SQL-HAVING-2"> <refsect2 id="R2-SQL-HAVING-2">
<REFSECT2INFO> <refsect2info>
<DATE>1998-04-15</DATE> <date>1998-09-06</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
HAVING clause HAVING clause
</TITLE> </title>
<PARA> <para>
The optional HAVING condition has the general form: The optional HAVING condition has the general form:
<Synopsis> <synopsis>
HAVING <REPLACEABLE CLASS="PARAMETER">cond_expr</REPLACEABLE> HAVING <replaceable class="PARAMETER">cond_expr</replaceable>
</Synopsis> </synopsis>
where <REPLACEABLE CLASS="PARAMETER">cond_expr</REPLACEABLE> is the same where <replaceable class="PARAMETER">cond_expr</replaceable> is the same
as specified for the WHERE clause. as specified for the WHERE clause.</para>
<Para> <para>
HAVING specifies a grouped table derived by the elimination HAVING specifies a grouped table derived by the elimination
of groups from the result of the previously specified clause of groups from the result of the previously specified clause
that do not meet the <REPLACEABLE CLASS="PARAMETER">cond_expr</REPLACEABLE>. that do not meet the <replaceable class="PARAMETER">cond_expr</replaceable>.</para>
<Para> <para>
Each column referenced in <REPLACEABLE CLASS="PARAMETER">cond_expr</REPLACEABLE> shall unambiguously Each column referenced in <replaceable class="PARAMETER">cond_expr</replaceable> shall unambiguously
reference a grouping column. reference a grouping column.
</PARA> </para>
</REFSECT2> </refsect2>
<REFSECT2 ID="R2-SQL-ORDERBYCLAUSE-2"> <refsect2 id="R2-SQL-ORDERBYCLAUSE-2">
<REFSECT2INFO> <refsect2info>
<DATE>1998-04-15</DATE> <date>1998-09-06</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
ORDER BY clause ORDER BY clause
</TITLE> </title>
<PARA> <para>
<Synopsis> <synopsis>
ORDER BY <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> [ASC | DESC] [, ...] ORDER BY <replaceable class="PARAMETER">column</replaceable> [ASC | DESC] [, ...]
</Synopsis> </synopsis></para>
<PARA> <para>
<REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> can be either a column <replaceable class="PARAMETER">column</replaceable> can be either a column
name or an ordinal number. name or an ordinal number.</para>
<PARA> <para>
The ordinal numbers refers to the ordinal (left-to-right) position The ordinal numbers refers to the ordinal (left-to-right) position
of the column. This feature makes it possible to define an ordering of the column. This feature makes it possible to define an ordering
on the basis of a column that does not have a proper name. on the basis of a column that does not have a proper name.
This is never absolutely necessary because it is always possible assign a name This is never absolutely necessary because it is always possible assign a name
to a calculated column using the AS clause, e.g.: to a calculated column using the AS clause, e.g.:
<ProgramListing> <programlisting>
SELECT title, date_prod + 1 AS newlen FROM films ORDER BY newlen; SELECT title, date_prod + 1 AS newlen FROM films ORDER BY newlen;
</ProgramListing> </programlisting></para>
<PARA> <para>
The columns in the ORDER BY must appear in the SELECT clause. The columns in the ORDER BY must appear in the SELECT clause.
Thus the following statement is illegal: Thus the following statement is illegal:
<ProgramListing> <programlisting>
SELECT name FROM distributors ORDER BY code; SELECT name FROM distributors ORDER BY code;
</ProgramListing> </programlisting></para>
<PARA> <para>
Optionally one may add the keyword DESC (descending) Optionally one may add the keyword DESC (descending)
or ASC (ascending) after each column name in the ORDER BY clause. or ASC (ascending) after each column name in the ORDER BY clause.
If not specified, ASC is assumed by default. If not specified, ASC is assumed by default.</para>
</REFSECT2> </refsect2>
<REFSECT2 ID="R2-SQL-UNION-2"> <refsect2 id="R2-SQL-UNION-2">
<REFSECT2INFO> <refsect2info>
<DATE>1998-04-15</DATE> <date>1998-09-06</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
UNION clause UNION clause
</TITLE> </title>
<PARA> <para>
<Synopsis> <synopsis>
<REPLACEABLE CLASS="PARAMETER">table_query</REPLACEABLE> UNION [ALL] <REPLACEABLE CLASS="PARAMETER">table_query</REPLACEABLE> <replaceable class="PARAMETER">table_query</replaceable> UNION [ALL] <replaceable class="PARAMETER">table_query</replaceable>
[ORDER BY <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> [ASC | DESC] [, ...] ] [ORDER BY <replaceable class="PARAMETER">column</replaceable> [ASC | DESC] [, ...] ]
</Synopsis> </synopsis>
where where
<REPLACEABLE CLASS="PARAMETER">table_query</REPLACEABLE> <replaceable class="PARAMETER">table_query</replaceable>
specifies any select expression without an ORDER BY clause. specifies any select expression without an ORDER BY clause.</para>
<PARA> <para>
The UNION operator specifies a table derived from a Cartesian product. The UNION operator specifies a table derived from a Cartesian product.
The two tables that represent the direct operands of the UNION must The two tables that represent the direct operands of the UNION must
have the same number of columns, and corresponding columns must be have the same number of columns, and corresponding columns must be
of compatible data types. of compatible data types.</para>
<PARA> <para>
By default, the result of UNION does not contain any duplicate rows By default, the result of UNION does not contain any duplicate rows
unless the ALL clause is specified. unless the ALL clause is specified.</para>
<Para> <para>
Multiple UNION operators in the same SELECT statement are evaluated left to right. Multiple UNION operators in the same SELECT statement are evaluated left to right.
Note that the ALL keyword is not global in nature, being applied only for the current pair of Note that the ALL keyword is not global in nature, being applied only for the current pair of
table results. table results.</para>
</REFSECT2> </refsect2></refsect1>
<REFSECT1 ID="R1-SQL-SELECT-2"> <refsect1 id="R1-SQL-SELECT-2">
<TITLE> <title>
Usage Usage
</TITLE> </title>
<PARA> <para>
</PARA> To join the table <literal>films</literal> with the table
<ProgramListing> <literal>distributors</literal>:
--Join table films with their distributors: </para>
-- <programlisting>
SELECT f.title, f.did, d.name, f.date_prod, f.kind SELECT f.title, f.did, d.name, f.date_prod, f.kind
FROM distributors d, films f FROM distributors d, films f
WHERE f.did = d.did; WHERE f.did = d.did
title |did|name | date_prod|kind title |did|name | date_prod|kind
-------------------------+---+----------------+----------+---------- -------------------------+---+----------------+----------+----------
...@@ -382,11 +387,12 @@ Usage ...@@ -382,11 +387,12 @@ Usage
The King and I |109|20th Century Fox|1956-08-11|Musical The King and I |109|20th Century Fox|1956-08-11|Musical
Das Boot |110|Bavaria Atelier |1981-11-11|Drama Das Boot |110|Bavaria Atelier |1981-11-11|Drama
Bed Knobs and Broomsticks|111|Walt Disney | |Musical Bed Knobs and Broomsticks|111|Walt Disney | |Musical
</ProgramListing> </programlisting>
<para>
<ProgramListing> To sum the column <literal>len</literal> of all films and group
--sum column "len" of all films group by "kind": the reults by <literal>kind</literal>:
-- </para>
<programlisting>
SELECT kind, SUM(len) AS total FROM films GROUP BY kind; SELECT kind, SUM(len) AS total FROM films GROUP BY kind;
kind |total kind |total
...@@ -396,12 +402,14 @@ Usage ...@@ -396,12 +402,14 @@ Usage
Drama | 14:28 Drama | 14:28
Musical | 06:42 Musical | 06:42
Romantic | 04:38 Romantic | 04:38
</ProgramListing> </programlisting>
<ProgramListing> <para>
--sum column length of all films group by "kind" To sum the column <literal>len</literal> of all films, group
--having total duration < 5 hours: the reults by <literal>kind</literal> and show those group totals
-- that are less than 5 hours:
</para>
<programlisting>
SELECT kind, SUM(len) AS total SELECT kind, SUM(len) AS total
FROM films FROM films
GROUP BY kind GROUP BY kind
...@@ -411,11 +419,13 @@ Usage ...@@ -411,11 +419,13 @@ Usage
----------+------ ----------+------
Comedy | 02:58 Comedy | 02:58
Romantic | 04:38 Romantic | 04:38
</ProgramListing> </programlisting>
<para>
<ProgramListing> The following two examples are identical ways of sorting the individual
--The following two examples are identicals: results according to the contents of the second column
-- (<literal>name</literal>):
</para>
<programlisting>
SELECT * FROM distributors ORDER BY name; SELECT * FROM distributors ORDER BY name;
SELECT * FROM distributors ORDER BY 2; SELECT * FROM distributors ORDER BY 2;
...@@ -434,12 +444,16 @@ Usage ...@@ -434,12 +444,16 @@ Usage
111|Walt Disney 111|Walt Disney
112|Warner Bros. 112|Warner Bros.
108|Westward 108|Westward
</ProgramListing> </programlisting>
<ProgramListing> <para>
--union of table distributors and table actors: This example shows how to obtain the union of the tables
-- (only those that begin with letter W): <literal>distributors</literal> and
-- <literal>actors</literal>, restricting the results to those that begin
with letter W in each table. Only distinct rows are to be used, so the
ALL keyword is omitted:
</para>
<programlisting>
-- distributors: actors: -- distributors: actors:
-- did|name id|name -- did|name id|name
-- ---+------------ --+-------------- -- ---+------------ --+--------------
...@@ -447,16 +461,14 @@ Usage ...@@ -447,16 +461,14 @@ Usage
-- 111|Walt Disney 2|Warren Beatty -- 111|Walt Disney 2|Warren Beatty
-- 112|Warner Bros. 3|Walter Matthau -- 112|Warner Bros. 3|Walter Matthau
-- ... ... -- ... ...
--
--select only distinct rows (without ALL):
--
SELECT distributors.name SELECT distributors.name
FROM distributors FROM distributors
WHERE distributors.name LIKE 'W%' WHERE distributors.name LIKE 'W%'
UNION UNION
SELECT actors.name SELECT actors.name
FROM actors FROM actors
WHERE actors.name LIKE 'W%'; WHERE actors.name LIKE 'W%'
name name
-------------- --------------
...@@ -466,88 +478,91 @@ Usage ...@@ -466,88 +478,91 @@ Usage
Warren Beatty Warren Beatty
Westward Westward
Woody Allen Woody Allen
</ProgramListing> </programlisting>
</REFSECT1> </refsect1>
<REFSECT1 ID="R1-SQL-SELECT-3"> <refsect1 id="R1-SQL-SELECT-3">
<TITLE> <title>
Compatibility Compatibility
</TITLE> </title>
<PARA> <para>
</PARA> </para>
<REFSECT2 ID="R2-SQL-SELECT-4"> <refsect2 id="R2-SQL-SELECT-4">
<REFSECT2INFO> <refsect2info>
<DATE>1998-04-15</DATE> <date>1998-09-06</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
<Acronym>SQL92</Acronym> <acronym>SQL92</acronym>
</TITLE> </title>
<PARA> <para>
</PARA> </para>
<REFSECT3 ID="R3-SQL-SELECT-1"> <refsect3 id="R3-SQL-SELECT-1">
<REFSECT3INFO> <refsect3info>
<DATE>1998-04-15</DATE> <date>1998-04-15</date>
</REFSECT3INFO> </refsect3info>
<TITLE> <title>
SELECT clause SELECT clause
</TITLE> </title>
<PARA> <para>
In the <Acronym>SQL92</Acronym> standard, the optional keyword "AS" is just noise and can be In the <acronym>SQL92</acronym> standard, the optional keyword "AS"
omitted without affecting the meaning. is just noise and can be
The <ProductName>Postgres</ProductName> parser requires this keyword when omitted without affecting the meaning.
renaming columns because the type extensibility features lead to parsing ambiguities The <productname>Postgres</productname> parser requires this keyword when
in this context. renaming columns because the type extensibility features lead to
parsing ambiguities
<PARA> in this context.</para>
In the <Acronym>SQL92</Acronym> standard, the new column name specified in an
"AS" clause may be referenced in GROUP BY and HAVING clauses. This is not currently <para>
allowed in <ProductName>Postgres</ProductName>. In the <acronym>SQL92</acronym> standard, the new column name
</PARA> specified in an
</REFSECT3> "AS" clause may be referenced in GROUP BY and HAVING clauses.
This is not currently
<REFSECT3 ID="R3-SQL-UNION-1"> allowed in <productname>Postgres</productname>.
<REFSECT3INFO> </para>
<DATE>1998-04-15</DATE> </refsect3>
</REFSECT3INFO>
<TITLE> <refsect3 id="R3-SQL-UNION-1">
UNION clause <refsect3info>
</TITLE> <date>1998-09-06</date>
<PARA> </refsect3info>
The <Acronym>SQL92</Acronym> syntax for UNION allows an additional CORRESPONDING BY clause: <title>
<Synopsis> UNION clause
<REPLACEABLE CLASS="PARAMETER">table_query</REPLACEABLE> UNION [ALL] </title>
[CORRESPONDING [BY (<REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> [,...])]] <para>
<REPLACEABLE CLASS="PARAMETER">table_query</REPLACEABLE> The <acronym>SQL92</acronym> syntax for UNION allows an
</Synopsis> additional CORRESPONDING BY clause:
<synopsis>
<Para> <replaceable class="PARAMETER">table_query</replaceable> UNION [ALL]
The CORRESPONDING BY clause is not supported by <ProductName>Postgres</ProductName>. [CORRESPONDING [BY (<replaceable class="PARAMETER">column</replaceable> [,...])]]
</PARA> <replaceable class="PARAMETER">table_query</replaceable>
</REFSECT3> </synopsis></para>
</REFSECT2> <para>
</REFSECT1> The CORRESPONDING BY clause is not supported by
</REFENTRY> <productname>Postgres</productname>.
</para>
<!-- </refsect3>
<REPLACEABLE CLASS="PARAMETER">
</REPLACEABLE> </refsect2>
<ReturnValue></ReturnValue> </refsect1>
<PARA> </refentry>
</PARA>
<VARIABLELIST> <!-- Keep this comment at the end of the file
<VARLISTENTRY> Local variables:
<TERM>&bull; mode: sgml
</TERM> sgml-omittag:t
<LISTITEM> sgml-shorttag:t
<PARA> sgml-minimize-attributes:nil
</PARA> sgml-always-quote-attributes:t
</LISTITEM> sgml-indent-step:1
</VARLISTENTRY> sgml-indent-data:t
</VARIABLELIST> sgml-parent-document:nil
<PARA> sgml-default-dtd-file:"../reference.ced"
</PARA> sgml-exposed-tags:nil
sgml-local-catalogs:"/usr/lib/sgml/catalog"
sgml-local-ecat-files:nil
End:
--> -->
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment