Documentation Source Text

Check-in [573431382a]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Reword some testable statements related to scalar subqueries in lang_expr.html.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 573431382acf5eb33d69c084ea2f4d357a07537a
User & Date: dan 2010-09-02 19:21:27.000
Context
2010-09-02
23:37
Tweaks to the formatting of the requirements traceability matrix. (check-in: e4a472e7f6 user: drh tags: trunk)
19:21
Reword some testable statements related to scalar subqueries in lang_expr.html. (check-in: 573431382a user: dan tags: trunk)
11:52
Add section to lang_expr.html for the EXISTS operator. (check-in: c8e9d99b1d user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to pages/lang.in.
1578
1579
1580
1581
1582
1583
1584
1585













1586

1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
EXISTS operator evaluates to 1. ^If executing the SELECT would return
no rows at all, then the EXISTS operator evaluates to 0. 

<p>^The number of columns in each row returned by the SELECT statement
(if any) and the specific values returned have no effect on the results
of the EXISTS operator. ^In particular, rows containing NULL values are
not handled any differently from rows without NULL values.














<h3>Table Column Names</h3>

<p>^A column name can be any of the names defined in the [CREATE TABLE]
statement or one of the following special identifiers: "<b>ROWID</b>",
"<b>OID</b>", or "<b>_ROWID_</b>".
^These special identifiers all describe the
unique integer key (the [rowid]) associated with every 
row of every table.
^The special identifiers only refer to the row key if the [CREATE TABLE]
statement does not define a real column with the same name.
^The rowid can be used anywhere a regular
column can be used.</p>

<h3>Subqueries</h3>
<p>^[SELECT] statements can appear in expressions as either the
right-hand operand of the IN or NOT IN operators, as a scalar quantity, or
as the operand of an EXISTS operator.
^As a scalar quantity or the operand of an IN or NOT IN operator,
the SELECT may have only a single column in its
result.  ^Compound SELECTs (connected with keywords like UNION or
EXCEPT) are allowed in any subquery.
^With the EXISTS operator, the columns in the result set of the [SELECT] are
ignored and the expression returns TRUE if one or more rows exist
and FALSE if the result set is empty.
^If no terms in the [SELECT] expression refer to values in the containing
query, then the expression is evaluated once prior to any other
processing and the result is reused as necessary.  ^If the [SELECT] expression
does contain variables from the outer query, then the [SELECT] is reevaluated
every time it is needed.</p>

<p>^When a SELECT appears within an expression but is not the right
operand of an IN or NOT IN operator, then the first row of the result of the
SELECT becomes the value used in the expression.  ^If the SELECT yields
more than one result row, all rows after the first are ignored.  ^If
the SELECT yields no rows, then the value of the SELECT is NULL.</p>

<tcl>hd_fragment castexpr {CAST expression}</tcl>
<h3>CAST expressions</h3>

<p>A CAST expression is used to convert the value of &lt;expr&gt; to 
a different [storage class] in a similar way to the conversion that takes
place when a [column affinity] is applied to a value. ^Application of a CAST








>
>
>
>
>
>
>
>
>
>
>
>
>

>











<
|
|
<
<
<
<
<
|
<
<
<
<
<
|
<
|
<
|
<
<
<







1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611

1612
1613





1614





1615

1616

1617



1618
1619
1620
1621
1622
1623
1624
EXISTS operator evaluates to 1. ^If executing the SELECT would return
no rows at all, then the EXISTS operator evaluates to 0. 

<p>^The number of columns in each row returned by the SELECT statement
(if any) and the specific values returned have no effect on the results
of the EXISTS operator. ^In particular, rows containing NULL values are
not handled any differently from rows without NULL values.

<h3>Scalar Subqueries</h3>

<p>^A [SELECT] statement enclosed in parentheses may appear as a scalar
quantity. ^A [SELECT] used as a scalar quantity must return a result set
with a single column. ^The result of the expression is the value of the
only column in the first row returned by the SELECT statement. ^If the SELECT 
yields more than one result row, all rows after the first are ignored. ^If
the SELECT yields no rows, then the value of the expression is NULL.

<p>^All types of [SELECT] statement, including aggregate and compound SELECT
queries (queries with keywords like UNION or EXCEPT) are allowed as scalar
subqueries.

<h3>Table Column Names</h3>

<p>^A column name can be any of the names defined in the [CREATE TABLE]
statement or one of the following special identifiers: "<b>ROWID</b>",
"<b>OID</b>", or "<b>_ROWID_</b>".
^These special identifiers all describe the
unique integer key (the [rowid]) associated with every 
row of every table.
^The special identifiers only refer to the row key if the [CREATE TABLE]
statement does not define a real column with the same name.
^The rowid can be used anywhere a regular
column can be used.</p>


<p>^A [SELECT] statement used as either a scalar subquery or as the 
right-hand operand of an IN, NOT IN or EXISTS expression may contain 





references to columns in the outer query. Such a subquery is known as





a correlated subquery. ^A correlated subquery is reevaluated each time

its result is required. ^An uncorrelated subquery is evaluated only once

and the result reused as necessary.




<tcl>hd_fragment castexpr {CAST expression}</tcl>
<h3>CAST expressions</h3>

<p>A CAST expression is used to convert the value of &lt;expr&gt; to 
a different [storage class] in a similar way to the conversion that takes
place when a [column affinity] is applied to a value. ^Application of a CAST